Prarthana Hegde
Prarthana Hegde

Reputation: 361

Javascript window.close() workarounds don't work on Chrome

Before anyone marks this question as duplicate, I would like to say that all the other answers are from 2014 or older. The workarounds or hacks do NOT work anymore on the updated versions of Chrome.

I have a logout page that needs to be closed upon clicking a link. I have read about how Javascript cannot close the window if the same script hasn't opened the window.

I am currently using Javascript to achieve this. How can this be done? (Basically, shut the tab using Javascript).

I have tried the latest answers such as:

var win = window.open("window.opener.location", "_self");
win.close();

which don't work anymore! Any help is appreciated.

Upvotes: 0

Views: 618

Answers (1)

alexandre
alexandre

Reputation: 345

You can only close windows/tabs that you create yourself. That is, you cannot programmatically close a window/tab that the user creates.

For example, if you create a window with window.open() you can close it with window.close().

Upvotes: 0

Related Questions