NOTE: This script has 1 requirement that the page to be closed cannot be the original page. It must be opened as a new window. If you wish to close a page that has been posted via form, the page must first have still been opened in a separate window. If you are running any security programs, test the sample page first with them disabled if you are having issues. I have not seen any examples of modern browsers not working with this script if the above requirement has been met.
Most versions do not work anymore due to security restrictions. The close option specification expects that it cannot be closed by anything other than the script that opened it… so this workaround basically attempts to reopen a window then close it:
I am calling it from a button press so it is **user initiated**, and it is still working fine using Chrome 35-40, Internet Explorer 11, Safari 7-8, and ALSO Firefox 35-40. I tested using version 8.1 of Windows and Mac OS X 10.6, 10.9 & 10.10.
The complete code:
The launcher window (window_close_tester.htm):
The opened window (window_to_close.htm):
Try this test page: