.iframe的使用A域中有parent.html,B域中有child.html.B域中的服务器要监听所有B域下所有child.html,并且两个域之间要交换数据.那么在A域中嵌入iframe
如: parent.html
<iframe hieght=0 width=0 id="child" name="child" src="访问路径+child.html"></iframe>
document.domain =IP //A域的IP或域名(去掉www)
函数function thisparent(){
alert("This is parent");
}
document.getElementById("child").contentWindow.thischild();
child.html
document.domain=IP//A域的IP或域名(去掉www)
function thischild(){
alert("This is child");
}
parent.thispatent();
如: parent.html
<iframe hieght=0 width=0 id="child" name="child" src="访问路径+child.html"></iframe>
document.domain =IP //A域的IP或域名(去掉www)
函数function thisparent(){
alert("This is parent");
}
document.getElementById("child").contentWindow.thischild();
child.html
document.domain=IP//A域的IP或域名(去掉www)
function thischild(){
alert("This is child");
}
parent.thispatent();