它适用于Firefox 20.0.1和IE 10.0.9200.16442,但两个输入元素都无法在Chrome 26.0.1410.64米document.getElementById(“myFrame”)。contentWindow.myFrameFunction()在Chrome 26.0.1410.64中无效m
Chrome的控制台显示此:
遗漏的类型错误:房产 '说' 对象[对象全局]是不是一个函数
============ ============ main.html =======================
function say() {
alert("parent.html------>I'm at parent.html");
}
function callChild()
{
var ifrm = document.getElementById("myFrame");
ifrm.contentWindow.say();
}
< input type=button value="invoke say() in the child.html" onclick="callChild()" />
< iframe id="myFrame" name="myFrame" src="child.html" />
======================== child.html ===================== ==
function say()
{
alert("child.html--->I'm at child.html");
}
function callParent() {
window.parent.say();
}
< input type=button value="invoke function say() in the parent.html" onclick="callParent()" />
你确定FF和IE浏览器正在正确的吗?也许铬是正确的! say()不是contentWindow < - global的对象的函数,换句话说,如果不打开其打开对象的原型,就不能使用jquery。 – 2013-05-13 03:32:25