4

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

Rakhitha Nimesh
  • 1,393
  • 2
  • 16
  • 26

2 Answers2

7

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
-5
window.open('','_self');
window.close();
Leigh
  • 28,765
  • 10
  • 55
  • 103
anon
  • 1