[英]How do I close a browser on click button HTML code?
How do I close a browser window with HTML code?如何关闭带有 HTML 代码的浏览器窗口?
all browser compatibality所有浏览器兼容性
window.close(); window.close(); not working
不工作
See the second reply below for a discussion on when the window can be closed:有关何时可以关闭窗口的讨论,请参阅下面的第二个回复:
window.close and self.close do not close the window in Chrome window.close 和 self.close 不会关闭 Chrome 中的窗口
I'm quoting the answer of this question我引用了这个问题的答案
Scripts are not allowed to close a window that a user opened.
不允许脚本关闭用户打开的窗口。 This is considered a security risk.
这被视为安全风险。 Though it isn't in any standard, all browser vendors follow this (Mozilla docs).
尽管它不是任何标准,但所有浏览器供应商都遵循此(Mozilla 文档)。 If this happens in some browsers, it's a security bug that (ideally) gets patched very quickly.
如果这种情况发生在某些浏览器中,那么这是一个安全漏洞,(理想情况下)会很快得到修补。
Use window.close() for close the window or tab in javascript
$(".close-btn").click(function(event) {
window.close();
});
Try window.top.close();试试 window.top.close(); or window.close();
或 window.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.