天天看點

javaScript建立無邊框iframe相容ie

<script>

var m_iframe=document.createElement("iframe");

m_iframe.scrolling="no";

m_iframe.setAttribute("frameborder", "0", 0);  //m_iframe.frameborder="0";ie7無效

m_iframe.src="http://www.cnblogs.com/cssfirefly";

document.body.appendChild(m_iframe);

</script>

注意:

m_iframe.frameborder="0"; 替換為m_iframe.setAttribute("frameborder", "0", 0);就可以了

IE7下動态建立Iframe時,在IE裡面的屬性有大小寫區分,是以frameBorder與frameborder是不同屬性

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

this.frame.setAttribute("frameborder", "0", 0);後面那個'0'表示忽略大小寫。

setAttribute:

object.setAttribute(sName, vValue [, iFlags])       
參數:       
sName 必填項. String類型,屬性名
vValue 必填項. 為屬性指定的變量,可以為string, number, 或者 Boolean類型
iFlags 選填. 下面指定的兩種 Integer 類型的标志
覆寫同名屬性.
1 預設值. 為屬性添加指定的值.

cssfirefly

http://cssfirefly.cnblogs.com