[英]Unable to close the browser window
我正在使用打开窗户
var childWindow = window.open('test.php','test',attributes);
在test.php中,我有一个插入数据的表单,应关闭onclick提交按钮。 为此,我正在编写window.close();
点击提交按钮,但我无法关闭窗口。 请帮帮我..
谢谢。
因此,如果您打开一个窗口:
window.open("test.php", "test");
您可以关闭该窗口:
window.close("test");
从MDN:
[ https://developer.mozilla.org/en-US/docs/Web/API/Window.open][1]
How do I know whether a window I opened is still open?
You can test for the existence of the window object reference which
is the returned value in case of success of the window.open()
call and then verify that windowObjectReference.closed
return value is false.
因此,在打开弹出窗口的主窗口中-运行setInterval函数以检测windowObjectReference.closed是否返回false
var myOpenWindow=window.open(...)
var interval = window.setInterval(function() {
try {
if (myOpenWindow == null || myOpenWindow.closed) {
window.clearInterval(interval);
//do something
}
}
catch (e) {
}
}, "seconds to poll");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.