www.webdeveloper.com
Results 1 to 14 of 14

Thread: close Firefox window automatically

  1. #1
    Join Date
    Apr 2006
    Posts
    49

    close Firefox window automatically

    I use window.close(); to close Firefox.

    I call this function after running some other code, and close it at last automatically. It works in IE but in Firefox, I have to click on Firefox anywhere once, then it will be closed, otherwise, its not closed.

    Does someone know why would Firefox has such behavior? How to overcome it?
    Thanks.

  2. #2
    Join Date
    Feb 2006
    Posts
    2,927
    call window.focus() before calling window.close()

  3. #3
    Join Date
    Dec 2004
    Location
    New York, USA
    Posts
    194
    I use self.close instead of window.close. Not sure if that makes a difference.

  4. #4
    Join Date
    Apr 2006
    Posts
    49
    I tried to place window.focus() in the front, I also tried to use self.close(), but none of them works. I still have to click on the page once to make it closed.
    Please help.

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Did you use Javascript to open the window? Javascript can only close windows that were opened using Javascript.

  6. #6
    Join Date
    Oct 2008
    Posts
    12

    resolved firefox autoclose

    To close a window not opened with JavaScript you will have to change the Firefox options...

    go to "about:config"
    and set the value of "dom.allow_scripts_to_close_windows" to true...

    Aniscartujo.

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by aniscartujo View Post
    To close a window not opened with JavaScript you will have to change the Firefox options...

    go to "about:config"
    and set the value of "dom.allow_scripts_to_close_windows" to true...

    Aniscartujo.
    You can not tell all the people who visit your site: "Hey, if you have FF, go to 'about:config'...".

    There is no way to close a window which was not opened by javascript, unless you persuade the user to change his browser's settings when visiting your page - which is absurd.

  8. #8
    Join Date
    Oct 2008
    Posts
    12

    Lightbulb This is only for knowledge...

    This is only for knowledge...

    I am just saying that is possible... (Certainly only for testing purposes on your own PC... but is possible...)

    You cannot force a user to change its configuration... but if you want to test some script that need to self close that will work... or maybe test some of the IE behavior on Firefox...

    Aniscartujo

  9. #9
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Even where the browser does accept the close command it will only close the current tab and not the wole browser (unless that is the only tab open).

  10. #10
    Join Date
    Feb 2009
    Location
    Sweden
    Posts
    2

    Lightbulb Solution to close window in Firefox without need to open it initially by javascript.

    Hi guys --

    This is a wonderful workaround for this problem. As an added benefit, it will also allow you to close a window in explorer 7, without the user needing to confirm closing the window.

    First you create a file called: close.html

    In this file you put the following code in your body tag:
    Code:
    <script language="javascript" type="text/javascript">window.close();</script>
    Then in the file that produces the window you want to close by using javascript, you insert the following code:
    Code:
    window.open('close.html','_self');
    The best way to use this is to include it in a link or formsubmit of course. If it is a link then the code would look like this:
    Code:
    <a href="javascript:window.open('close.html','_self');">Link_text</a>
    So to close a firefox window with javascript, we simply open a new window, and in that newly opened windowed, we close it...

    I stumbled upon this solution (http://naver.kaist.ac.kr/Windows/149) for explorer 7 when trying to avoid a user dialog when closing a window..

    The great thing is that it works just as well for this firefox issue.

    Have a great day -- greetings from Sweden
    Last edited by toby_blond; 02-19-2009 at 11:57 AM.

  11. #11
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    If your page closes your visitor's browser and they had several other important pages open at the same time then the next thing that those visitors will be doing is searching for your address so that they can organise your horrible death,

  12. #12
    Join Date
    Sep 2008
    Location
    On the Interweb
    Posts
    125
    Quote Originally Posted by felgall View Post
    if your page closes your visitor's browser and they had several other important pages open at the same time then the next thing that those visitors will be doing is searching for your address so that they can organise your horrible death,
    rofl

  13. #13
    Join Date
    Feb 2009
    Location
    Sweden
    Posts
    2
    Quote Originally Posted by felgall View Post
    If your page closes your visitor's browser and they had several other important pages open at the same time then the next thing that those visitors will be doing is searching for your address so that they can organise your horrible death,
    hahaha -- welcome to the deep dark forrests of Sweden to hunt me down =)

    This solution should only be used when you create a new page as a "popup". And afterwards want to close just that page with java-script when a user clicks on a link or submits a form.

    It does not close down the entire browser unless it is the only window open - which would not be the case in the previous mentioned scenario...

  14. #14
    Join Date
    Aug 2013
    Posts
    2

    Wink

    Quote Originally Posted by aniscartujo View Post
    To close a window not opened with JavaScript you will have to change the Firefox options...

    go to "about:config"
    and set the value of "dom.allow_scripts_to_close_windows" to true...

    Aniscartujo.
    Thanks for your suggestion I waited just for this since 2 days

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles