js文件里给iframe的变量赋值遇问题

JavaScript026

js文件里给iframe的变量赋值遇问题,第1张

先把array[i] =document.getElementById(ifr).contentWindow.document.getElementById(i)里的ifr加上引号,使之成为字符串,再调试下,看报什么错。你上面写的是ife,不是ifr。

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