◎让IFRAME框架内网页的背景透明
先在框架标签加上allowtransparency=true;
<iframe name="vfrs" src="vfrs.htm" width="760" height="122" scrolling="no" border="0" marginwidth="0" marginheight="0" frameborder="0" allowtransparency="true">
然后在来源网页vfrs.htm的body标签内加上bgcolor=transparent
例:<body bgcolor=transparent>
◎实现IFRAME框架内文档的背景透明
<iframe src="about:<body style='background:transparent'>" allowtransparency></iframe>
IE5.5和NN6以上的浏览器支持Frame,Iframe对象的allowTransparency方法,如果某对象的背景颜色设置为Transparency的,它将继承包含它容器的特性。我们可以通过这个特性实现透明背景的开/关。
代码如下:
a.html如下:
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</HEAD>
<BODY style="BACKGROUND-COLOR: transparent">
<H1>透明文档</H1>
<P>此IFRAME无背景颜色</P>
<P>BODY:<br><BODY STYLE="background-color:transparent"></P></BODY></HTML>
iframe
<IFRAME ID="frame1" SRC="a.html" allowTransparency="true" HEIGHT=180 WIDTH=300> </IFRAME>