美文网首页
JS中Iframe之间传值的方法

JS中Iframe之间传值的方法

作者: mtian999 | 来源:发表于2017-05-24 17:01 被阅读0次

1. 在iframe子页面中获取父页面的元素:

    a>window.parent.document这个是获取父页面document中的对象;
    b>如果要获取父页面js中的方法:window.parent.xxxx();xxxx()为方法;

2. 在父页面中获取iframe子页面中的元素:

      a>
     var child = document.getElementByIdx_x("mainFrame").contentWindow;//mainFrame这个id是父页面iframe的id
     child.document;//获取子页面中的document对象;

相关文章

网友评论

      本文标题:JS中Iframe之间传值的方法

      本文链接:https://www.haomeiwen.com/subject/wssoxxtx.html