Return to Snippet

Revision: 62642
at March 4, 2013 20:15 by apphp-snippets

Initial Code
<!-- Sample #1: form button -->
<input type=button value="Close This Window" onclick="javascript:window.close();">
<!-- Sample #2: text link  -->
<a href="javascript:window.close();">Click Here to Close Window</a>
<!-- Sample #3: close window after a given number of seconds -->
<body onload="setTimeout(window.close, 10000)">...</body>

Initial URL

Initial Description
The function that closes window is very useful when you use a pop-up window on your page, because it allows the visitor to easily close the window. You can also do it several ways: to use a button, a text link or make the window closes automatically after a given number of seconds.

Initial Title
Close Window in JavaScript

Initial Tags
javascript, window

Initial Language