Javascript document.getElementById(";myFrame";).contentWindow.myFrameFunction()赢得';t在铬合金26.0.1410.64 m中工作
它适用于Firefox 20.0.1和IE 10.0.9200.16442,但这两种输入元素在Chrome 26.0.1410.64 m中都不起作用 Chrome控制台显示: 未捕获的TypeError:对象[object global]的属性“say”不是函数 =====================================main.html=======================Javascript document.getElementById(";myFrame";).contentWindow.myFrameFunction()赢得';t在铬合金26.0.1410.64 m中工作,javascript,dom,iframe,Javascript,Dom,Iframe,它适用于Firefox 20.0.1和IE 10.0.9200.16442,但这两种输入元素在Chrome 26.0.1410.64 m中都不起作用 Chrome控制台显示: 未捕获的TypeError:对象[object global]的属性“say”不是函数 =====================================main.html======================= function say() { alert("parent.html------&g
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" />
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()" />
函数say(){
警报(“parent.html----->我在parent.html”);
}
函数callChild()
{
var ifrm=document.getElementById(“myFrame”);
ifrm.contentWindow.say();
}
=====================================child.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" />
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()" />
函数say()
{
警报(“child.html--->我在child.html”);
}
函数callParent(){
window.parent.say();
}
父.html中的
我的原型bla-bla是错误的,但是从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();
}
你确定FF和IE工作正常吗?也许chrome是对的!say()不是ContentWindow对象的函数window.say显示了函数代码,而top.say和this.parent.say未定义。此外,chrome还提示不安全的JavaScript试图使用URL访问框架。。。。。。域、协议和端口必须匹配。