Home >Web Front-end >HTML Tutorial >javaScript creates borderless iframe compatible with ie_html/css_WEB-ITnose

javaScript creates borderless iframe compatible with ie_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:34:071005browse

3f1c4e4b6b16bbbd69b2ee476dc4f83a
var m_iframe=document.createElement("iframe");
m_iframe.scrolling="no";

m_iframe.setAttribute(" frameborder", "0", 0); //m_iframe.frameborder="0";ie7 is invalid

m_iframe.src="http://www.cnblogs.com/cssfirefly";
document .body.appendChild(m_iframe);

2cacc6d41bbb37262a98f745aa00fbf0

Note:

m_iframe.frameborder="0"; Replace with m_iframe.setAttribute("frameborder" , "0", 0); that's it

When dynamically creating an Iframe under IE7, the attributes in IE are case-sensitive, so frameBorder and frameborder are different attributes

this.frame.setAttribute("frameborder", "0", 0);

this.frame.setAttribute("frameborder", "0", 0); The '0' at the end means that case is ignored.

setAttribute:

object.setAttribute(sName, vValue [, iFlags]) 
 参数: 
sName
sName 必填项. String类型,属性名
vValue 必填项. 为属性指定的变量,可以为string, number, 或者 Boolean类型
iFlags 选填. 下面指定的两种 Integer 类型的标志
0 覆盖同名属性.
1 默认值. 为属性添加指定的值.
Required. String type, attribute name
vValue

Required. The variable specified for the attribute can be string, number, or Boolean type

iFlags
Optional. The two Integer type flags specified below 1
0 override the properties of the same name.
Default value. Add the specified value to the attribute.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn