Use open() to open a window and close() to close the window:
let myWindow;
function openWin() {
myWindow = window.open("", "myWindow", "width=200, height=100");
}
function closeWin() {
myWindow.close();
}
Try it Yourself »
More examples below.
The close()
method closes a window.
window.close()
NONE |
NONE |
Open "www.91xjr.com" in a new window, and use close() to close it:
function openWin() {
myWindow = window.open("https://www.91xjr.com", "_blank", "width=200, height=100");
}
function closeWin() {
myWindow.close();
}
Try it Yourself »
close()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!