[英]Close Tab Chrome/Safari Browser - Javascript
I am trying to close Chrome/Safari browser tab using javascript.我正在尝试使用 javascript 关闭 Chrome/Safari 浏览器选项卡。 I tried all the below code.
我尝试了以下所有代码。 But nothing is working.
但没有任何工作。
open('about:blank', '_self').close(); - This opens up a new tab, and the user is able to browse back. Which is not required.
open(location, '_self').close(); - Scripts may close only the windows that were opened by it.
window.open('','_parent','');
window.close(); - Not working
Is it a browser restriction?是浏览器限制吗?
The window.close doesn't work because it doesn't know what to close try this window.close 不起作用,因为它不知道要关闭什么试试这个
//Global var to store a reference to the opened window
var openedWindow;
function openWindow() {
openedWindow = window.open('moreinfo.htm');
}
function closeOpenedWindow() {
openedWindow.close();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.