2013-05-13 42 views
0

它适用于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()" /> 
+0

你确定FF和IE浏览器正在正确的吗?也许铬是正确的! say()不是contentWindow < - global的对象的函数,换句话说,如果不打开其打开对象的原型,就不能使用jquery。 – 2013-05-13 03:32:25

回答

0

我的原型喇嘛喇嘛是错误的,但看到其中的差别在自己的iframe调用时

function callParent() { 
    console.log(window.say); //childs.say function 
    console.log(top.say); //parents.say function 
    console.log(self.say, this.parent.say); //more fun! 
    //window.parent.say(); 
} 
+0

window.say显示功能代码,而top.say和this.parent.say未定义。另外,Chrome会提示不安全的JavaScript尝试访问带有URL的帧......域,协议和端口必须匹配。 – 2013-05-13 06:47:53

相关问题