Rakhitha Nimesh
Rakhitha Nimesh

Reputation: 1441

Closing the Browser tab using js or jquery

I want to close the current browser tab by clicking a button. window.close method does not work.

Upvotes: 4

Views: 12800

Answers (2)

anon
anon

Reputation: 1

window.open('','_self');
window.close();

Upvotes: -5

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You can't close the current browser tab with javascript. It would be annoying for the user if sites start to close themselves like this without the user intent so browsers simply do not allow this. Don't forget that the notion of a browser tab is not defined anywhere in the HTML nor the EcmaScript specifications, some browsers don't even have tabs.

You could of course write a plugin that you will install on your client's browser that will do the job.

Upvotes: 7

Related Questions