0
我有一個窗口,點擊打開。打開的窗口將不會關閉
function PopupManager() {
this.name = "_popupmanager_";
this.windows = {};
};
PopupManager.prototype.open = function(url, option, size, name) {
var url = "http://google.com"
var option = "null, status=no, toolbar=no, menubar=no, titlebar=no,
location=no, scrollbars=no, resizable=no"
var size = 'height=200, width = 814'
this.windows[name] = window.open(url, option, size, name);
this.windows[name].focus();
};
PopupManager.prototype.closeAll = function() {
for (name in this.windows) {
this.closeWindow(name);
}
}
PopupManager.prototype.closeWindow = function(name) {
if (this.windows[name]) {
if (!this.windows[name].closed) {
this.windows[name].opener.name="indexpage";
this.windows[name].close();
}
delete this.windows[name];
}
};
//初始化
document.getElementById("popupManager").onclick = function (e) {
e.preventDefault();
var popupManager = new PopupManager();
popupManager.open('http://www.google.com', 'google');
}
而且我想這應該關閉同一個窗口。
document.getElementById("closeIt").onclick = function (e) {
e.preventDefault();
var popupManager = new PopupManager();
popupManager.closeAll();
popupManger.closeWindow();
}
無控制檯錯誤&沒有任何反應。只是不會關閉。
我試圖使用相同的< a>標籤打開&使用if語句關閉窗口,但我無法弄清楚。所以現在我試圖使用兩個不同的< a>標記(是的,我知道這是愚蠢的),一個打開&一個關閉,但我甚至不能這樣做。
我甚至無法弄清楚我在這裏做錯了什麼。
任何幫助將不勝感激。嘆...
試着打開你的同一個來源的窗口,讓我知道結果 – Mouneer
我打開窗口w同一起源;我已經爲此問題提供了google.com,以便該問題不會因爲位置或特定位置而變得過於具體。 – HackYa
好吧你關閉窗口內的同一個腳本打開它嗎?或者從另一個腳本窗口本身? – Mouneer