在 Firefox 3 中回发后 window.dialogArguments 属性被重置。回发后,尝试设置 window.dialogArguments 属性会产生错误。检查该属性时,其值未定义。这很奇怪,因为就在模态窗口打开时,该属性似乎已创建并且可以访问。此行为仅在回发后发生。这是 Firefox 3 的已知错误吗,因为自版本 4 以来 IE 中的方法 showModalDialog 刚刚实现。如何解决这个问题?
最佳答案
如果 window.dialogArguments 属性未定义,您可以直接通过 window.opener.myObject 使用该对象:
开场白
m_oArgs = new Object;
m_oArgs.Foo = "";
window.showModalDialog("http://myUrl/dialog.aspx", m_oArgs, 'dialogWidth:350px;dialogHeight:140px;');
alert(m_oArgs.Foo)
对话
var DA = window.dialogArguments;
if (DA != null) {
DA.Foo = "MyArgument";
} else {
if ((!window.opener.closed) && (window.opener.m_oArgs)) {
window.opener.m_oArgs.Foo = "MyArgument";
}
}
关于javascript - window.dialogArguments 在 Firefox 3 showModalDialog 函数中回发后重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6213996/