【发布时间】:2013-12-15 09:42:37
【问题描述】:
我有一个父 Web 表单,它在单击按钮时打开了一个子窗口
我需要做的是在子窗口仍然打开时直接关闭父窗体,子窗口也应该关闭。
我已经为它编写了以下 javascript
var opengridacc;
function OpenGridAccounts(companyId, checkRequestType, documentId) {
var hdnDocumentId = $(document).find('#hdnDocumentId').val();
documentId = hdnDocumentId;
opengridacc = window.open("../CheckRequest/GridAccounts.aspx?comp_id=" + companyId
+ "&CheckRequestType=" + checkRequestType
+ "&DocumentId=" + documentId,
"GridAccounts", "height=755px,width=1280px,center=yes,status=no,scrollbars=yes,toolbar=no,menubar=no,left=0,top=0");
return false;
}
function closegrdacc() {
if(!opengridacc) {
opengridacc.close();
}
}
但是 ie 给出了一个错误,即 close 是未定义的
【问题讨论】:
-
你不是说 if (opengridacc) 吗?与!运算符,您正在检查 opengridacc 是否不存在!
-
unable to get property 'close' of undefined or null reference 是我得到的错误
-
即使我注释了 If 条件,也会出现同样的错误
-
需要检查opengridacc是否存在,否则会报错。再次尝试“if (opengridacc) {…”
-
当我刷新页面时,'opengridacc' 未定义
标签: c# javascript jquery asp.net