Bookmark and Share

How to close a browser window in javascript without warning message

This warning message shows up every time one tries to close browser window with window.close() function. It seems impossible to close the most outer main browser window and not to get this message.

But wait... window.close() function implementation is just so simple. It checks window.opener. If "opener" equals empty string it suspects that we talk about parent window (not the one that was opened with and pop-ups warning. And it is easy to work around:

< a href="javascript:window.opener='x';window.close();">Close< /a>