JS中Iframe之间传值的方法

网络编程 发布日期:2024/10/11 浏览次数:1

正在浏览:JS中Iframe之间传值的方法

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对象;