Created
November 4, 2012 20:18
-
-
Save apphp-snippets/4013504 to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Sample #1: form button --> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-close-window */ | |
| <form> | |
| <input type=button value="Close This Window" onclick="javascript:window.close();"> | |
| </form> | |
| <!-- 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment