Firefox 2.0: closing a window

Discussion in 'Javascript' started by Andre, Oct 26, 2006.

  1. Andre

    Andre Guest

    With Firefox 1.5+, I used the following code to close a window/tab:
    ===
    <html><head>
    <script language="javascript" type="text/javascript">
    function closeWindow() {
    window.open('','_parent','');
    window.close();
    }
    closeWindow();
    </script></head><body></body></html>
    ===
    Since I upgraded to Firefox 2.0, it does not work - the window/tab
    stays open.

    Any idea how I can "load a page" that would force a window/tab close?

    André
     
    Andre, Oct 26, 2006
    #1
    1. Advertising

  2. Andre

    Andre Guest

    Randy Webb wrote:
    > Andre said the following on 10/26/2006 6:50 PM:
    > > With Firefox 1.5+, I used the following code to close a window/tab:

    >
    > The fact that it even works in FF is amazing.
    >
    > <snip>
    >
    > > Since I upgraded to Firefox 2.0, it does not work - the window/tab
    > > stays open.

    >
    > That is a good thing. It means script cant close a window/tab it didn't
    > open.
    >
    > > Any idea how I can "load a page" that would force a window/tab close?

    >
    > I hope not.


    I understand why this would normally not be something desirable
    (loading a page just to see the browser close...), however I found it
    useful for my purpose.

    Here's the context:

    I wrote an web-app (crunchy.sf.net; python-based with some sprinkle of
    javascript) that uses Firefox as its GUI: upon starting the app, it
    open a new firefox window or, if one was already open, would open a new
    tab. I have a menu with a "quit button" which closes the app (python
    back-end) and used to close the Firefox window/tab that was open.

    >
    > P.S. That code doesn't open a window for me in IE nor FF.


    Here's a confirmation that it does (did) work for some people:
    http://www.interwebby.com/blog/2006/02/04/3/

    (It was not the original place I found this "trick", but is one
    example...)

    André
    >
    > --
    > Randy
     
    Andre, Oct 27, 2006
    #2
    1. Advertising

  3. Andre

    Randy Webb Guest

    Andre said the following on 10/26/2006 6:50 PM:
    > With Firefox 1.5+, I used the following code to close a window/tab:


    The fact that it even works in FF is amazing.

    <snip>

    > Since I upgraded to Firefox 2.0, it does not work - the window/tab
    > stays open.


    That is a good thing. It means script cant close a window/tab it didn't
    open.

    > Any idea how I can "load a page" that would force a window/tab close?


    I hope not.

    P.S. That code doesn't open a window for me in IE nor FF.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 27, 2006
    #3
  4. Andre

    Randy Webb Guest

    Andre said the following on 10/26/2006 7:09 PM:
    > Randy Webb wrote:
    >> Andre said the following on 10/26/2006 6:50 PM:
    >>> With Firefox 1.5+, I used the following code to close a window/tab:

    >> The fact that it even works in FF is amazing.
    >>
    >> <snip>
    >>
    >>> Since I upgraded to Firefox 2.0, it does not work - the window/tab
    >>> stays open.

    >> That is a good thing. It means script cant close a window/tab it didn't
    >> open.
    >>
    >>> Any idea how I can "load a page" that would force a window/tab close?

    >> I hope not.

    >
    > I understand why this would normally not be something desirable
    > (loading a page just to see the browser close...), however I found it
    > useful for my purpose.


    It's a security flaw, it has no useful purpose.

    > Here's the context:
    >
    > I wrote an web-app (crunchy.sf.net; python-based with some sprinkle of
    > javascript) that uses Firefox as its GUI: upon starting the app, it
    > open a new firefox window or, if one was already open, would open a new
    > tab. I have a menu with a "quit button" which closes the app (python
    > back-end) and used to close the Firefox window/tab that was open.


    Flip them back to the front page of the app.

    >> P.S. That code doesn't open a window for me in IE nor FF.

    >
    > Here's a confirmation that it does (did) work for some people:
    > http://www.interwebby.com/blog/2006/02/04/3/
    >
    > (It was not the original place I found this "trick", but is one
    > example...)


    I never said it didn't work for some people. Short of a video of it
    happening (which I won't do), I can only tell you - without doubt - that
    it does NOT open a new window/tab for me in IE7, FF 1.5.0.7 nor in Opera 9.

    The only thing it does do is close the active tab/window.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 27, 2006
    #4
  5. Andre

    Randy Webb Guest

    Randy Webb said the following on 10/27/2006 7:52 AM:
    > Andre said the following on 10/26/2006 7:09 PM:
    >> Randy Webb wrote:
    >>> Andre said the following on 10/26/2006 6:50 PM:
    >>>> With Firefox 1.5+, I used the following code to close a window/tab:


    Firefox 2.0 gives the very accurate error message:

    Scripts may not close windows that were not opened by script.

    Why FF1.5 didn't is up for speculation.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 27, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2lsZWVzaA==?=
    Replies:
    4
    Views:
    33,925
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Oct 14, 2004
  2. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    657
    Thomas Hansen
    Feb 15, 2007
  3. thomas
    Replies:
    0
    Views:
    230
    thomas
    Oct 23, 2003
  4. karthi
    Replies:
    0
    Views:
    123
    karthi
    Jan 31, 2006
  5. Tony
    Replies:
    10
    Views:
    317
    Randy Webb
    Feb 22, 2007
Loading...

Share This Page