I am neither an HTML or Javascript programmer. I create HTML pages by using reference material and researching Web sites, such as this Forum.
What I want to do is “Close” an HTML page by clicking a button, labeled “Exit”, placed within the page. It would take the place of clicking the “X” Close Icon in the upper right hand corner of the page. I have tried using the following HTML code:
<INPUT type=”button” value=”Exit!” onclick=”window.close()”>
This code works fine with Internet Explorer but does not work with Netscape or Mozilla Firefox. Can anyone help me with a code, be it HTML, javascript XML etc., that will close the HTML page, reguardless of which of the 3 browsers are used? Thanks Richard
Mystery solved. Thanks to Jona for providing:
“The code will work in Firefox only if a script opens the new window. You cannot use JavaScript to close a window unless that window was opened by JavaScript. This is usually the case with Internet Explorer as well, only IE displays an alert message. If you want to close the current window, you must open it with JavaScript as well.”