How can I close a browser window without receiving the Do you want to close this window prompt?
The prompt occurs when I use the window.close();
function.
Generally speaking, it is a good practice to close your web browser after accessing any website that requires a username and password. It is especially important when you are on a public computer. It ensures that the next person to use that computer won't be surfing the net as you.
No, you can't disable the close button on any web site. This would be a major security concern.
window.open('', '_self', ''); window.close();
This works for me.
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.
None of the hacks in the answers on this question work any longer, and if someone would come up with another dirty hack, eventually it will stop working as well.
I suggest you don't waste energy fighting this and embrace the method that the browser so helpfully gives you — ask the user before you seemingly crash their page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With