js脚本实现iframe框架自适应高度

来源:互联网 发布:淘宝李宁官网是正品吗 编辑:程序博客网 时间:2024/05/16 17:32
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
         function getFrameHeight(idname) {
            var ifm = document.getElementById(idname);
            var subWeb = document.frames ? document.frames[idname].document : ifm.contentDocument;
            if (ifm != null && subWeb != null) {
                ifm.height = subWeb.body.scrollHeight;
            }
        }
    </script>
</head>
<body scroll="no" style="overflow: hidden;" onload="getFrameHeight(500)">
    <form id="form1" runat="server">
    <iframe id="iframeCheck" name="iframeCheck" scrolling="no" frameborder="0"
        src="#" width="100%" height="500" onload="getFrameHeight(this.id)">
    </iframe>
    </form>
</body>
</html>