zoukankan      html  css  js  c++  java
  • 页面中加载iframe的常见问题总结

    1、页面引用ifram

    <iframe src="URL" id="iframe" name="iframe" frameborder="0" marginwidth="0" align="left"  height="550px" width="100%" scrolling="auto" marginheight="0"
        onload="setIframeHeight()">
    </iframe>

    2、高度自适应,避免出现滚动条

    /** iframe高度自适应 **/
    function setIframeHeight() {
      var iframe =  document.getElementById("iframe");
      if (iframe) {
        var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
        if (iframeWin.document.body) {
          iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
        }
      }
    }
    /** 改变页面大小是触发 **/
    window.onresize=function(){
      setIframeHeight();
    }

    3、父页面获取iframe对象

    var iframe = window.frames["iframe"];
    var xxx = iframe.document.getElementById("xxx").value;

    4、ifame获取父页面对象

    var parWin = parent.window;
  • 相关阅读:
    (floyd+DP) zoj 3027
    (树形DP) acdream 1028
    acdream 1032
    (BFS) acdream 1191
    (树形DP) bzoj 1060
    (状态压缩DP) poj 2978
    (DP) codeforces 358D
    (DP+二分) hdu 3433
    (最大生成树) hdu 3367
    hdoj 3501
  • 原文地址:https://www.cnblogs.com/hugang2017/p/7605927.html
Copyright © 2011-2022 走看看