Firefox 2.0: closing a window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andre

    Firefox 2.0: closing a window

    With Firefox 1.5+, I used the following code to close a window/tab:
    ===
    <html><head>
    <script language="javas cript" 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é

  • Randy Webb

    #2
    Re: Firefox 2.0: closing a window

    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.javas cript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Andre

      #3
      Re: Firefox 2.0: closing a window


      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:


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

      André

      --
      Randy

      Comment

      • Randy Webb

        #4
        Re: Firefox 2.0: closing a window

        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:

        >
        (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.javas cript FAQ - http://jibbering.com/faq
        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

        Comment

        • Randy Webb

          #5
          Re: Firefox 2.0: closing a window

          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.javas cript FAQ - http://jibbering.com/faq
          Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

          Comment

          Working...