在IE的frame中确实有这样的问题,
只有在body的size改变的时候才会激发onsize事件。
你可以在frameset中进行处理。例如:<html> 
<head> 
<title>
</title> 
</head> 
<script language="javascript">
var i=0;
function doFunc()
{
i++;
window.status = i ;
}
</script>
<SCRIPT FOR="window" EVENT="onresize" LANGUAGE="JavaScript">
      doFunc();
</SCRIPT>
<frameset rows="100,*" frameborder="0"> 
<frame src="head.html" /> 
<frameset cols="150,*" frameborder="0">  
<frame src="left.html" />  
<frame src="desktop.html" name="main"/> 
</frameset> 
</frameset>
<noframes>
</noframes> 
</html>

解决方案 »

  1.   

    我不能把onresize响应代码写在框架页面中。
    因为框架是要可以随时加载其它页面的
    我需要的是在Desktop中处理页面的大小问题
      

  2.   

    这个也不发生冲突呀。
    可以把事件的处理函数放到frame中。
    每次事件激发的时候判断一下frame对象中的相应方法是否存在,
    存在的话,调用执行。还有一个办法,
    就是使用计时器。
    看到一个老外的页面中是用计时器实现的。
      

  3.   

    简单的说,我要Desktop在被嵌在frame中的时候,也能正确响应onresize事件
    但不要在框架页面中加任何js代码,能做到吗?
      

  4.   

    一定要在frame中使用onresize是办不到的。
    可以使用定时器定时查询来模拟这个事件。
      

  5.   

    呵呵,问题我自己解决啦
    代码贴出来供大家参考function winResize()
    {
        var str="width="+document.documentElement.clientWidth;
        str+="<br/>height="+document.documentElement.clientHeight;
        msg.innerHTML=str;
    }
    if(window.frameElement!=null)
    {
        window.frameElement.attachEvent("onresize",winResize);
    }
    else
    {
        window.attachEvent("onresize",winResize);
    }
      

  6.   

    我也遇到了这样的问题,刚解决了,其实很简单,既然iframe页面的onresize事件不起作用,那就监听父页面的onresize事件就行了。确实如果iframe页面有设定固定大小,父页面在改变页面大小时,如果高度或宽度小于iframe页面的高度或宽度,iframe页面的onresize事件就会失效。但父页面的onresize事件并没有失效,所以只要监听父页面的onresize事件,然后在该时间里重设定iframe页面的内容大小就OK了。
    以下是在你代码的基础上修改的:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Test</title>
    <script language="javascript" type="text/javascript">
    window.parent.window.onresize=function()
    {//内容不需要作任何改变
        var str="width="+document.documentElement.clientWidth;
        str+="<br/>height="+document.documentElement.clientHeight;
        msg.innerHTML=str;
    }
    </script>
    </head>
    <body>
    <p>&nbsp;</p>
        <div style="overflow:hidden;height:1px; width:500px; background-color:Red;"></div>
        <span id="msg"></span>
    </body>
    </html>