<body onload="self.close();"> won't work on Firefox 1.0.7?

Discussion in 'Javascript' started by stevong, Jan 19, 2006.

  1. stevong

    stevong Guest

    It works on Konquerer though. I remember it works on IE too.

    I've tried window.close() too. Doesn't work on Firefox also.

    I've also tried to create a function. It doesnt work on Firefox also.
    Bottomline is: Firefox doesn't accept window.close() or self.close()?

    Are there ways to rectify the issue?

    Please advise.
    Thanks

    Steven.
     
    stevong, Jan 19, 2006
    #1
    1. Advertising

  2. stevong wrote:

    > I've also tried to create a function. It doesnt work on Firefox also.
    > Bottomline is: Firefox doesn't accept window.close() or self.close()?


    It depends on the browser settings whether script is allowed to do
    certain things like closing windows. Usually script can only close a
    window that has been opened by script (window.open) but Mozilla probably
    can be configured to completely disallow script to close windows.

    Firefox 1.5 gives a message
    "Scripts may not close windows that were not opened by script."
    in the JavaScript console if window.close() fails on a window that has
    not been opened by script. I think Firefox 1.0.x does the same but can't
    check currently.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 19, 2006
    #2
    1. Advertising

  3. stevong

    RobG Guest

    Martin Honnen wrote:
    >
    >
    > stevong wrote:
    >
    >> I've also tried to create a function. It doesnt work on Firefox also.
    >> Bottomline is: Firefox doesn't accept window.close() or self.close()?

    >
    >
    > It depends on the browser settings whether script is allowed to do
    > certain things like closing windows. Usually script can only close a
    > window that has been opened by script (window.open) but Mozilla probably
    > can be configured to completely disallow script to close windows.


    I tried in Firefox 1.5 to modify the dom.popup_allowed_events entry to
    allow close, but it didn't work.

    The rule seems to be that only a script in the opener page can close a
    popup without user action. The OP could put a close function in the
    parent and call that from the popup's load event.


    In the opener:

    var popA;
    function openWin(){ popA = window.open('x.html','PopA',''); }
    function closeMe(x){ if (x.close) x.close(); }


    In the popup:

    <body onload="opener.closeMe(this);">


    But what is the point of having a window close itself onload?

    [...]


    --
    Rob
     
    RobG, Jan 20, 2006
    #3
  4. stevong

    Randy Webb Guest

    RobG said the following on 1/19/2006 8:25 PM:
    > Martin Honnen wrote:
    >>
    >>
    >> stevong wrote:
    >>
    >>> I've also tried to create a function. It doesnt work on Firefox also.
    >>> Bottomline is: Firefox doesn't accept window.close() or self.close()?

    >>
    >>
    >> It depends on the browser settings whether script is allowed to do
    >> certain things like closing windows. Usually script can only close a
    >> window that has been opened by script (window.open) but Mozilla
    >> probably can be configured to completely disallow script to close
    >> windows.

    >
    > I tried in Firefox 1.5 to modify the dom.popup_allowed_events entry to
    > allow close, but it didn't work.
    >
    > The rule seems to be that only a script in the opener page can close a
    > popup without user action. The OP could put a close function in the
    > parent and call that from the popup's load event.
    >
    >
    > In the opener:
    >
    > var popA;
    > function openWin(){ popA = window.open('x.html','PopA',''); }
    > function closeMe(x){ if (x.close) x.close(); }
    >
    >
    > In the popup:
    >
    > <body onload="opener.closeMe(this);">
    >
    >
    > But what is the point of having a window close itself onload?


    The way I read the OP was that they wanted to close the original window.

    Page1 is loading.
    Page1 opens a new window sans features.
    Page1 finishes loading.

    (Thats my hypothetical scenario to attempt to understand what they
    wanted to do)

    OP wanted to close Page1 was the way I read it. And no Gecko based
    browsers allow it.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jan 20, 2006
    #4
    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. Walter Beierdonck

    Self.close() window without the dialog close?Yes/NO

    Walter Beierdonck, Apr 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    347
    Grant Wagner
    Apr 30, 2004
  2. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    558
    Martin Honnen
    Nov 4, 2004
  3. Replies:
    3
    Views:
    183
  4. Replies:
    0
    Views:
    177
  5. liu

    <body onBlur="self.close()">

    liu, Jul 21, 2007, in forum: Javascript
    Replies:
    2
    Views:
    244
Loading...

Share This Page