Home  >  Article  >  Web Front-end  >  iframe父子页面操作-比较好用的两个方法-window.parent/oframe.contentWindow.document_html/css_WEB-ITnose

iframe父子页面操作-比较好用的两个方法-window.parent/oframe.contentWindow.document_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:52:361491browse

发现比较好用的iframe父子页面操作方法,记录一下


1.父页面 test.html


 


 获取iframe    var oframe = document.getElementById("main")


获取子页面  var child =  oframe.contentWindow.document


获取子页面元素      var test = child.getElementById("test")


获取子页面高度   var childh = child .body.offsetHeight


获取子页面高度


2.子页面 iframe.html


 


  获取父页面   var parent = window.parent.document


注意:需要把代码放在服务器端,才能兼容google浏览器


 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn