zoukankan      html  css  js  c++  java
  • iframe交互(一)父页面自动高度

    //父页面源码
    <body style="border:1px solid red;200px;height:500px;" onload="IFrameResize()">
        <script>
            function IFrameResize() {
                //alert(this.document.body.scrollHeight); //弹出当前页面的高度 
                var obj = parent.document.getElementById("childFrame"); //取得父页面IFrame对象 
                //alert(obj.height); //弹出父页面中IFrame中设置的高度 
                obj.height = this.document.body.scrollHeight; //调整父页面中IFrame的高度为此页面的高度 
            }
    
        </script>
        <script type="text/javascript" src="./auto-height.js"></script>
    </body>
    //子页面源码
    <body>
        <IFRAME border=0 marginWidth=0 frameSpacing=0 marginHeight=0 src="iframe.html" frameBorder=0 noResize scrolling="no" width=100%
            height=100% vspale="0" id="childFrame"></IFRAME>
        <!-- <iframe id="iframe" name="asd" src="iframe.html" onload="loadIframe(this)" height="100" frameborder="0" style="border:1px solid blue">
        </iframe> -->
        <script type="text/javascript">
            function loadIframe(doc) {
                console.log(doc.contentWindow.document);
            }
        </script>
    </body>

    注意:调试时注意是否是本地启动,还是基于代理服务器。本地启动会触发作用于问题导致错误

  • 相关阅读:
    array with objects sort
    Vue组件之区域滚动
    ajax跨域请求问题总结
    常见contentType
    Sublime Text 3实用快捷键大全
    具有层级关系的扁平化数组转化成树形结构数组
    阿里云地图选择器
    前端解析二进制文件流并下载
    tool.js日常工具方法
    git操作
  • 原文地址:https://www.cnblogs.com/menu/p/7230204.html
Copyright © 2011-2022 走看看