彈出窗口用於允許用戶在單獨的窗口中打開文檔頁面。當用戶嘗試打開下一個文檔頁面時,必須關閉所有以前的文檔頁面窗口。使用javascript關閉多個彈出窗口
所以基本上,我想關閉多個彈出窗口。爲了保存打開的彈出窗口的引用,我將包含彈出窗口引用的數組保存在變量中,並將該變量的值保存在隱藏字段中。
現在,popup = window.open('', '', sOptions);
返回[object]
,並且當檢索此[object]
時,它會生成一個錯誤,該對象不支持此屬性或方法。
我用下面的JavaScript在我的web應用程序開發使用ASP/vb.net:
var popupWin = new Array();
function OnPopupClick(url,title,name) {
var popup = null;
var sOptions;
sOptions = 'status=yes,menubar=no,scrollbars=yes,resizable=yes,toolbar=no,titlebar=yes,location=0,directories=0';
sOptions = sOptions + ',width=' + (screen.availWidth - screen.availWidth/2).toString();
sOptions = sOptions + ',height=' + (screen.availHeight - 50).toString();
sOptions = sOptions + ',screenX=0,screenY=0'
sOptions = sOptions + ',left=' + ((screen.availWidth/2) - 10).toString();
sOptions = sOptions + ',top=0';
html = '<html><head><title>'+ title + '</title></head><body style="margin: 0px 0; text-align:center; "><IMG src="' + url + '" BORDER=0 NAME=image height="' + (screen.availHeight - 50).toString() +'" width="' + ((screen.availWidth - screen.availWidth/2)-20).toString() +'" onload="window.resizeTo((document.image.width-(document.image.width-(screen.availWidth - screen.availWidth/2)))+10,((document.image.height*1.3)-(screen.availHeight - 50))+((screen.availHeight - 50)*3)";></body></html>';
popup = window.open('', '', sOptions);
popup.document.open();
popup.document.write(html);
popup.document.focus();
popup.document.close();
if(document.getElementById('<%= hidTitle.ClientID %>').value!=name){
ClosePopupWin(document.getElementById('<%= hidWinRef.ClientID %>').value);
}
TrackPopupWinOpen(popup,name);
}
function TrackPopupWinOpen(winName,title) {
popupWin[popupWin.length] = winName;
var index = popupWin.length-1;
var val = popupWin.join();
document.getElementById('<%= hidWinRef.ClientID %>').value=val;
document.getElementById('<%= hidTitle.ClientID %>').value=title;
}
function ClosePopupWin(retVal) {
popupWin[popupWin.length]=retVal.split();
var openCount = popupWin.length;
for (i = 0; i < openCount; i++) {
popupWin[i].close();
}
}
我在做什麼錯?
我不能使用任何第三方工具。我只能使用asp中的控件。