hugang2017

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;

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-07-18
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2022-01-04
  • 2022-12-23
  • 2021-06-22
  • 2021-10-10
  • 2021-08-26
  • 2021-12-07
相关资源
相似解决方案