Skip to content Skip to sidebar Skip to footer

Alternative To Window.close() Method For Chrome And Firefox

I want to close my window/tab when the close button is clicked on the same page. I used window.close() method. It works perfectly for IE versions, but it doesn't work for Firefox a

Solution 1:

According to MDN

[Window.close()] is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.

So in order to use this method, you have to use the window.open() method to be able to close it via window.close().

Post a Comment for "Alternative To Window.close() Method For Chrome And Firefox"