简体   繁体   中英

How do I close a browser on click button HTML code?

How do I close a browser window with HTML code?

all browser compatibality

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

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). 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(); or window.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM