You are here

How to close the browser in javascript

Intuitively, you would think that if you want to close the main browser window, all you would need is:

window.close();

This will actually work on a "fresh" window, but if use has navigated away and back to the page, it may not work.

I have found the following to always work.

function CloseApplication() {
    window.open('', '_self', '');
    window.close(); 
}
Tags: 

Add new comment

Simple Copyright Policy: If you want to reproduce anything on this site, get my permission first.