Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I close a window with Javascript on Mozilla Firefox 3?

Tags:

People also ask

How do I close a window using JavaScript?

Simply call window. close() and it will close the current window. If it doesn't work... it should always work.

Can you close browser window in JavaScript?

JavaScript provides an in-built function named close() to close the browser window that is opened by using window. open() method.

How do I close a window in Firefox?

To close all of the Firefox windows at once on Windows or Linux, click the hamburger button (three horizontal lines) in the upper-right corner of any window. In the menu that appears, select “Exit.” You can also press Ctrl+Shift+Q on your keyboard.

How do I close a popup in JavaScript?

self. close(); should do it. That should work from within the popup.


I need to close the tab which displays my webpage, by the click of a button. But firefox does not allow to close the window by javascript as long as it is not opened by javascript. If I set the value of dom.allow_scripts_to_close_windows to be "true", then even normal window.close() works too. But that is not a good solution. :(

I tried the following workaround suggested in one of the forums:

<script language="javascript" type="text/javascript"> function closeWindow() {    window.open('','_parent','');    window.close(); } </script>  

It is supposed to fool the browser into thinking that it was actually opened by javascript, but this does not work in Firefox 3.

Can anyone please suggest a workaround?