首頁  >  文章  >  web前端  >  iframe父子页面操作-比较好用的两个方法-window.parent/oframe.contentWindow.document_html/css_WEB-ITnose

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

WBOY
WBOY原創
2016-06-24 11:52:361491瀏覽

发现比较好用的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浏览器


 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn