Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome和Firefox相当于IE';s window.opener.functionName()_Javascript_Html_Google Chrome_Firefox - Fatal编程技术网

Javascript Chrome和Firefox相当于IE';s window.opener.functionName()

Javascript Chrome和Firefox相当于IE';s window.opener.functionName(),javascript,html,google-chrome,firefox,Javascript,Html,Google Chrome,Firefox,我在IE中使用window.opener.functionName()从子窗口调用父函数,这非常好。然而,这在Chrome/Firefox中并不适用 我尝试了window.top.functionName();parent.window.top.functionName()和其他许多函数。没有人在工作 有人能帮忙吗 编辑 这是代码。 注意,我有两个层次结构。我需要从ChildCall2.jsp文件调用Parent.jsp的updateHTML()函数 Parent.jsp <!DOCTYP

我在IE中使用window.opener.functionName()从子窗口调用父函数,这非常好。然而,这在Chrome/Firefox中并不适用

我尝试了window.top.functionName();parent.window.top.functionName()和其他许多函数。没有人在工作

有人能帮忙吗

编辑
这是代码。
注意,我有两个层次结构。我需要从ChildCall2.jsp文件调用Parent.jsp的updateHTML()函数

Parent.jsp

<!DOCTYPE html>
<html>
<head>
<TITLE>Parent function call test</TITLE>
<script>
    function openwindow(url)
    {
         Hints=window.open(url, 'Hints', "resizable=yes,scrollbars=yes,width=475,height=225");
         if(Hints.blur)
            Hints.focus();
    }

    function updateHTML()
    {
        alert("Parent called successfully");
    }
</script>
</head>
<body onFocus="">
<a href="javascript:openwindow('ChildCall.jsp')"> Click Me </a>
</body> 
</html>

父函数调用测试
函数openwindow(url)
{
提示=window.open(url,‘提示’,“可调整大小=yes,滚动条=yes,宽度=475,高度=225”);
如果(提示.模糊)
focus();
}
函数updateHTML()
{
警报(“成功调用父级”);
}
ChildCall.jsp

<!DOCTYPE html>
<html>
<head>
<TITLE>Child function call test</TITLE>
<script>
    function openwindow(url)
    {
         Hints=window.open(url, 'Hints', "resizable=yes,scrollbars=yes,width=475,height=225");
         if(Hints.blur)
            Hints.focus();
    }

    function updateHTML1()
    {
        alert("Parent call function");
        window.opener.updateHTML();
    }
</script>
</head>
<body onFocus="">
<a href="javascript:openwindow('ChildCall2.jsp')"> Click Me </a>
</body> 
</html>

子函数调用测试
函数openwindow(url)
{
提示=window.open(url,‘提示’,“可调整大小=yes,滚动条=yes,宽度=475,高度=225”);
如果(提示.模糊)
focus();
}
函数updateHTML1()
{
警报(“父调用函数”);
window.opener.updateHTML();
}
ChildCall2.jsp

<!DOCTYPE html>
<html>
<head>
<TITLE>Child function2 call test</TITLE>
<script>
    function openwindow(url)
    {
         Hints=window.open(url, 'Hints', "resizable=yes,scrollbars=yes,width=475,height=225");
         if(Hints.blur)
            Hints.focus();
    }

    function updateHTML2()
    {
        alert("Parent call function2");
        window.opener.updateHTML1();
    }
</script>
</head>
<body onFocus="">
<a href="javascript:updateHTML2()"> Click Me to call parent function </a>
</body> 
</html>

子函数2调用测试
函数openwindow(url)
{
提示=window.open(url,‘提示’,“可调整大小=yes,滚动条=yes,宽度=475,高度=225”);
如果(提示.模糊)
focus();
}
函数updateHTML2()
{
警报(“父呼叫功能2”);
window.opener.updateHTML1();
}

您的所有弹出窗口都具有相同的名称
(window.open(url,'hits',…)
,这可能会使某些浏览器感到困惑,因此他们会识别出其他窗口是他们的打开窗口


只是一个旁注,检测一个窗口是否有
blur
方法是不必要的,只需执行
提示.focus()

在新创建的窗口的控制台中有任何错误吗?没有。没有错误。只是函数没有被调用。刷新窗口并再次查看控制台…你是对的。。获取此错误-
TypeError:window.opener.updateDocHTML不是主页上的函数
updateDocHTML
未定义。时间问题?在Chrome和FF中,在
updateDocHTML
之前或在
updateDocHTML中,某些IE-only代码会停止执行?