如何让iframe背景在IE下透明

有时候,我们会在网页里嵌套iframe,一般的浏览器(Firefox,Chrome等等)默认的背景是透明的,但IE浏览器(IE6/IE7/IE8)默认背景是白色的。那么如何让IE浏览器嵌套iframe背景也透明呢?

这个时候,我们就需要在iframe里面添加属性allowTransparency=”true”(true:允许透明)

注意:在iframe引进的head_nav.html页面的时候,不要设置head_nav.html页面html或body的背景颜色。(head_nav.html为你iframe导入的页面地址)

<iframe src=”head_nav.html” frameborder=”0″ scrolling=”no” width=”100%” height=”150″ allowTransparency=”true”></iframe>

友情提示:iframe里面链接的打开方式最好是target=”_blank”,不然你会看到悲剧的情景~