当前位置:编程学习 > JS >>

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

<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>

 

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,