一个HTML通过下面这种方式嵌入另外一个html<iframe id="aim" src="page1.html" frameBorder="0" width="100%" scrolling="yes" height="100%"></iframe>这个page1.html怎么没有充满当前页面啊。我html太菜了。

解决方案 »

  1.   


    就是最简单的一个html里面包含另外一个html
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>页面</title> <script type="text/javascript">
    </script>
    </head>
    <body>
    <iframe id="aim" src="page1.html" frameBorder="0" width="100%" scrolling="yes" height="100%"></iframe>
    </body>
    </html>
    请问在哪里设置什么外部包含高度宽度。
      

  2.   

    height属性是不支持百分比的。在page1.html里写上下面一段代码:
    <script language="javascript">
        parent.document.getElementById("aim").height = document.body.scrollHeight + 20;
    </script>
    加号后面的数字酌情增减。
      

  3.   

    给IFRAME设一个高度。或在外面用一个有高度的DIV包起来,或给BODY设一个高度。你可以加上这个,看一下不加高度的实际效果:
    <style>
    body {width:100%;height:100%;border:solid}
    </style>
      

  4.   

    $("#aim").load(function() { 
    $(this).height($(this).contents().height()); 
    });
    $("#aim").mouseover(function() { 
    $(this).height($(this).contents().height()); 
    });
    $("#aim").mouseout(function() { 
    $(this).height($(this).contents().height()); 
    });通过jquery控制
      

  5.   

    问题解决<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">把这段删掉 就OK了。
      

  6.   

    这个解决方法并不好。你可以查查关于DOCTYPE的资料。