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