关于Iframe在IE6下不显示的bug

mac2022-06-30  63

IE都出到IE8了,用IE6的人渐渐少了..但还是存在的.例如QAMM们在用.

所以,IE6下存在的问题也必须解决.这两天,我就遇到一个了:

 

html <table>    <tr>        <td id="tdTest" runat="server">            <iframe id="ifrTest" height="100%" runat="server"></iframe>        </td>    </tr></table>

 

Code     protected void Page_Load(object sender, EventArgs e)    {        this.ifrTest.Attributes.Add("src""ie6.aspx");    }

 

很简单的代码,就是嵌套一个Iframe,后台绑定Iframe显示页面内容,简单得很呢.可是,这么简单的代码在IE6下就死活不显示!!

为什么呢?问题就出现在那个height="100%"上了,在IE6下height不知是取不到还是取到td原来那个未给src赋值之前的0.反正就死活不显示.

知道是这个问题,就简单了..解决办法有N种:

1.去掉height="100%",不过不设置高度iframe显示不如人意.

2.后台给td或者iframe设置一个固定值:

 

Code2 this.tdTest.Height = "200px";

 

3.前台动态设置iframe的height:

 

Code3 this.ifrTest.Attributes.Add("onload""iframeAutoHeight(this)");

 

前台还得加上:(以下这段js来自网络)

 

script function iframeAutoHeight(obj){    var id = obj.id;    var subWeb = document.frames ? document.frames[id].document : obj.contentDocument;       if(obj != null && subWeb != null)    {        obj.height = subWeb.body.scrollHeight;    }   }   

 

4.自己想吧....

 

另外,网络上有说IE6下scr属性排在第一位就不能显示,但是我死活尝试不出来.如果谁知道,欢迎指教:kenblove#gmail.com

 

转载于:https://www.cnblogs.com/KenBlove/archive/2009/03/24/1420464.html

相关资源:IE6 innerHTML写入的iframe src不显示BUG的解决方法
最新回复(0)