Close Window in JavaScript

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.

[View All Snippets]
Show Plain Text »
  1. <!-- Sample #1: form button -->
  2. <form>
  3. <input type=button value="Close This Window" onclick="javascript:window.close();">
  4. </form>
  6. <!-- Sample #2: text link  -->
  7. <a href="javascript:window.close();">Click Here to Close Window</a>
  9. <!-- Sample #3: close window after a given number of seconds -->
  10. <body onload="setTimeout(window.close, 10000)">...</body>
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory

Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.

Quick Registration with: Facebook / Google