Note: A current window/tab will only get closed if and only if it was created & opened by that script.Means the window.close syntax is only allowed for the window/tab that is created & opened using window.open method.
Example: This example shows how to to open GeekForGeeks window and then close it.
When we load the code:
New Window/Tab gets opened up:
The Window/Tab gets closed:
The entire process:
- How to get the size of screen, current web page and browser window using jQuery?
- How to give a div tag 100% height of the browser window using CSS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.