Unified way to close browser window in JavaScript?

Is there a way to just close my browser window, guaranteed? Last time, when I heard, the call window.close()or self.close()only works when starting the current window from another window. Is there a way to force most browsers to close the current window if this is not the case?

+3
source share
3 answers

It is not possible to close the parent window using a script without a request in any major browser.

So no, no guarantees. In the child window window.closeand self.closework fine.

+8
source
+1

Try this (working in Chrome and IE) -

function closeWindow() { 
window.open('', '_self', '');
window.close();
} 
+1
source

Source: https://habr.com/ru/post/1791107/


All Articles