Is It Possible To Close A Browser Window Using Javascript?
Solution 1:
The reason it was not working in fire fox was due to some settings in the fire fox.
Please set your firefox browser:
1.input "about:config " to your firefox address bar and enter;
2.make sure your "dom.allow_scripts_to_close_windows" is true
window.close is now working in fire fox too.
Solution 2:
You have the first script tag twice, which might cause problems. You should also add the attribute type="text/javascript" so that you can be sure that the script is picked up by all browsers.
Solution 3:
What you want to do is undesirable for the user.
If a user loads your page and you as a webmaster decides that the main browser needs to close, then they will likely get seriously annoyed if you succeeded. Window history and such, gone.
Please explain EXACTLY why you want this. For example if you need to log someone out use location.replace('logout.php
)` and have that page log them out
There are hacks that I personally wish would be fixed - in this exact duplicate here: How can I close a browser window without receiving the "Do you want to close this window" prompt?
Solution 4:
When using the close
method you need to keep in mind an important thing: The close
method closes only windows opened by javascript using the open
method. Since you are trying to close the current window, you should use
self.close();
Also, you should remember that, users will get a confirmation, asking the user to choose whether the window is to be closed or not
Solution 5:
There a thousand things which work in IE but not in other browsers. I think window.close(); should server your purpose. It can be called on any event on your page.
Post a Comment for "Is It Possible To Close A Browser Window Using Javascript?"