请教各位大虾了
我有一个iframe,浏览器在打开的时候不是最大化,如果我把浏览器最大化之后,iframe的大小还是没有改变,还是浏览器刚打开时候的大小。请问如何解决这个问题呀,我就是想让它根据浏览器的大小改变,自动调整大小

解决方案 »

  1.   

    直接定义长宽100%
    <iframe width="100%" height="100%" src="http://www.baidu.com"></iframe>
      

  2.   

    怎么会不行呢,LZ试下这段代码
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title></head><body>
    <iframe width="100%" height="100%" src="http://www.baidu.com"></iframe>
    </body></html>
      

  3.   

    <body onresize="changeIframeSize()">用body的onresize事件也可以
      

  4.   

    <table cellpadding="0" cellspacing="0" width="100%" style="height:100%; margin:0; padding:0;">
    <tr>
    <td colspan="2" style="height:69px;margin:0; padding:0;"><iframe style="height:69px;" src="{{site_path}}frame/header/" name="header" width="100%" scrolling="no" frameborder="0"></iframe></td>
    </tr>
    <tr id='bodytr'>
    <td id='bodytd' valign="top" width="160" style="margin:0; padding:0;" ><iframe src="{{site_path}}frame/menu/" name="menu"  width="160" height="100%" scrolling="no" frameborder="0"></iframe></td>
    <td valign="top" width="100%" style="margin:0; padding:0;" ><iframe src="{{site_path}}frame/main/" name="main" width="100%" height="100%" frameborder="0" scrolling="yes" style="overflow:visible;"></iframe></td>
    </tr>
    </table>
    <script type="text/javascript">
     var height = document.body.offsetHeight
     var bodytr = document.getElementById('bodytr')
     bodytr.style.height = height - 69;
     //document.getElementById('bodytd').style.height = '100%';
     var Sys = {};
     var ua = navigator.userAgent.toLowerCase();
     window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] : 0 ;
     document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] : 0 ;
     window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = (ua.match(/chrome\/([\d.]+)/) ? ua.match(/chrome\/([\d.]+)/)[1] : '') : 0;
     window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] : 0;
     window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0; if (!Sys.ie){  document.getElementById('bodytd').style.height = '100%';}
     
    </script>
      

  5.   

    引用 3 楼 dickeychen 的回复:
    width="100%",不行啊
    怎么会不行呢,LZ试下这段代码
    HTML code<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title></head><body>
    <iframe width="100%" height="100%" src="http://www.baidu.com"></iframe>
    </body></html>
    ---------
    OK,这中方式可以,谢谢了