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 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 remove active nav-tab when click outside of nav-tab in Bootstrap ?
- How to get the size of screen, current web page and browser window using jQuery?
- How to open a hyperlink in another window or tab in HTML ?
- How to give a div tag 100% height of the browser window using CSS
- Java Program to Display Current Hour and Current Minute
- How to force tab-navigation to stay in place using Bootstrap ?
- How to check which tab is active using Material UI ?
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.
Improved By : nidhi_biet