uvinod uvinod - 3 months ago 13
Javascript Question

Close Current Tab

I have a close link on my web page. I would like to function it to close the current tab when click it. I have written

<a href="#" onclick = "javascript:self.close();">close</a>


The above code seems to be working well in Internet Explorer. But it is not working in Mozilla Firefox and Google Chrome. Please help me to resolve this.

Answer

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().

Comments