码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2014-12-09 12:23:28      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   ar   color   sp   on   div   bs   代码   html   

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


1.父页面 test.html


  <iframe id="iframe1" src="iframe.html"></iframe>


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


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


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


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


获取子页面高度


2.子页面 iframe.html


  <div id="test"></div>


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


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


 

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

标签:style   ar   color   sp   on   div   bs   代码   html   

原文地址:http://blog.csdn.net/yixiao_naihe/article/details/41820937

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!