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>

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

  • 相关阅读:
    一本通1402 Vigen&#232;re密码
    一本通1166 求f(x,n)
    一本通1083 计算星期几
    一本通1157 哥德巴赫猜想
    一本通1156 求π的值
    SpringBoot多数据源:动态数据源
    cron 表达式
    自定义异常类
    CentOS7 常用命令集合
    想要学好Git,应该掌握哪些基础知识?
  • 原文地址:https://www.cnblogs.com/menu/p/7230204.html
Copyright © 2011-2022 走看看