在Windows之间传递值的JavaScript在Firefox中不起作用

JavaScript that passes values between windows not working in Firefox

本文关键字:JavaScript Firefox 不起作用 Windows 之间      更新时间:2023-09-26

我已经看到了其他类似的问题,但我似乎仍然没有正确理解,我在我的ASPX页面上得到了这个JavaScript,但是它可以在IE和chrome中工作,但不能在Firefox中使用。我也尝试过FireBug插件,但它似乎没有帮助。

<script language="javascript" type="text/javascript">
            function PassValues() {
                window.opener.document.forms(0).submit();
                self.close();
            }

From SO itself: http://stackoverflow.com/questions/2678133/pass-a-value-from-parent-to-child-open-window

使用 window.open(( 方法设置引用:

var childWin = window.open("www.google.com" <etc.>);
Then treat childWin as a whole other window. For example,
childWin.document.getElementById('searchField')

将为您提供对 ID 为"搜索字段"的元素的引用。 等等。 冲洗并重复。

您的问题是使用 document.forms 作为可调用对象。 根据规格,事实并非如此。 试试window.opener.document.forms[0].submit()