Skip to content Skip to sidebar Skip to footer

Close Windows That Were Not Opened By Script Using Javascript

I want my web application to run in a window which has no menubar, addressbar etc. I have a Default.html page and in this page I click a 'Run Application' button which first opens

Solution 1:

You can't close the current window in firefox because you didn't open it. It doesn't matter that you loaded AutoClose.html into it.

But this whole business with windows is pointless. Most people have their browser set to open new windows in a new tab, and you can't prevent the menubar etc in a tab window.

I, personally, would be very irritated if you closed my window just because I used your application.

It could be the only window the user has open - in which case you just closed their browser. It could be they want to press back, and closing the tab will annoy them.

This error from firefox is correct, and if it works in Chrome that's a serious bug and you should report it.

Solution 2:

Simply,

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

Solution 3:

The basic problem is that what your requirements-setter wants you to do is explicitly blocked by Firefox:

  1. There is no way to hide the UI in a user's existing browser window, because it's user-hostile and a favorite tool of phishers.
  2. There is no way to close the user's existing window from script, losing all the user's session history in the process.

Basically, the user has other things in the browser than just your bank thing. So assuming otherwise is more or less doomed to failure.

Is there any way you can push back on the unreasonable requirements?

Solution 4:

This worked for me.

I used it to close the window when clicking a button in jQuery UI Dialog.

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

Post a Comment for "Close Windows That Were Not Opened By Script Using Javascript"