Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - closing tab

Tags:

javascript

Is it possible to close a tab via JavaScript?

For example, I have redirected user from email to my page, then I need to open pop-up window and close the tab I have redirected user to.

Does window.close() work only for windows created with JavaScript? Or is it possible to modify tab, so that becomes a popup window?

like image 607
Somebody Avatar asked Dec 29 '10 11:12

Somebody


2 Answers

window.close() is working only for windows created inside javascript?

window.close should also work for new windows your page has created using target="_blank". Other than that, there is no way to close the current window or tab programmatically. As far as I know, what you want to do - closing an original window that you have not opened - is impossible.

like image 87
Pekka Avatar answered Sep 20 '22 17:09

Pekka


No. You can only control child windows created inside a parent window.

"Is it possible to modify tab, so that it's become popup window?" Only if you have access to the page where it is created.

like image 39
Mads Mogenshøj Avatar answered Sep 19 '22 17:09

Mads Mogenshøj