当前位置: 代码迷 >> Web前端 >> iframe在IE中的透明有关问题与allowTransparency属性
  详细解决方案

iframe在IE中的透明有关问题与allowTransparency属性

热度:18   发布时间:2012-10-07 17:28:51.0
iframe在IE中的透明问题与allowTransparency属性
    使用iframe调用的页面,在IE下(不包括IE9)会以白色背景显示(被调用页面没有设置背景颜色,以及系统的背景颜色默认为白色),如何让其透明?

    网络上已经有很多答案:
   
    在iframe标签中加上 allowTransparency="true" 属性

    即:
 
   
<iframe src="iframe.html" width="600px" height="500px" allowtransparency="true"  scrolling="no" frameborder="0"></iframe>


     有人说,被调用的页面的body中要加上style="background-color:transparent",其实是没有必要的,在IE5.5以上(不包括)版本中,已经没有必要使用。

     allowTransparency属性是针对iframe的特殊属性,仅对ie起到一定的作用,而其属性值,即上文提到的“true”则是不必须的,也就是说只要iframe中有allowTransparency属性存在,无论其值为多少,哪怕是“false”,也会对IE中iframe的透明起到作用,这也自然说明,其不用定义值也可以起到作用,那么在iframe只用加入“allowTransparency”即可

     即:
 
   
<iframe src="iframe.html" width="600px" height="500px" allowtransparency  scrolling="no" frameborder="0"></iframe>


  相关解决方案