输入banner图图片脚本导航/分类

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

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