0

实际上,我正在尝试Javascript使用 .Everywhere 从子窗口访问父窗口的功能,window.opener但在 iPad Chrome 中它不起作用。我们可以解决这个问题吗?这将是很大的帮助。以下是我的代码的详细说明。

我有一个文件 test1.html(父文件)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
    function opentest2() {
        window.open('test2.html', '_blank');
    }
    function parentFunction() {    //This function does not execute.
        alert('called from parent'); 
    }
</script>
</head>     
<body>
<input type="button" value="openanother window" onclick="opentest2()"/>
</body>
</html>

我有另一个名为 test2.html 的文件(子文件)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
    function callingchild() {
        alert('hii');
        alert(window.opener);
        window.opener.parentFunction();
    }
</script>
</head>
<body>
<input type="button" value="call parent function" onclick="callingchild()"/>
</body>
</html>

我在 iPad chrome 中调试时添加了一些警报。但问题是我无法执行这个 parentFunction() 函数。我也尝试过window.parentwindow.top但两者都不起作用。

提前致谢

4

0 回答 0