Opera - .closed not accessible if window is closed?

Discussion in 'Javascript' started by Matt Kruse, Sep 7, 2003.

  1. Matt Kruse

    Matt Kruse Guest

    See: http://www.mattkruse.com/temp/window_closed.html

    It looks like the .closed property of a window is inaccessible if the
    window is actually closed. Other browsers have no problem detecting
    that the window has been closed. Opera 7.11 and 7.20b7 both throw
    errors when trying to check the .closed property.

    Is this a bug in Opera, or do I have to (once again) take special
    action to make normal javascript work with Opera?

    Matt Kruse
    (who still finds very few redeeming qualities in Opera...)
    Matt Kruse, Sep 7, 2003
    #1
    1. Advertising

  2. Matt Kruse

    andy johnson Guest

    On 7 Sep 2003 15:18:28 -0700, (Matt Kruse) wrote:

    >See: http://www.mattkruse.com/temp/window_closed.html
    >
    >It looks like the .closed property of a window is inaccessible if the
    >window is actually closed. Other browsers have no problem detecting
    >that the window has been closed. Opera 7.11 and 7.20b7 both throw
    >errors when trying to check the .closed property.
    >
    >Is this a bug in Opera, or do I have to (once again) take special
    >action to make normal javascript work with Opera?
    >
    >Matt Kruse
    >(who still finds very few redeeming qualities in Opera...)


    From what I understand about the design philosophy of Opera, that is
    so you won't pop up another annoying pop up in someones face. Cruising
    the Opera forums, newsgroups, KB and bug reports will tell you for
    sure. From a users point of view, Opera is pretty good, and definitely
    a good alternative to the crap microsoft puts out.

    Andy
    -
    "There would be a lot more civility in this world if people
    didn't take that as an invitation to walk all over you"
    - (Calvin and Hobbes)
    andy johnson, Sep 8, 2003
    #2
    1. Advertising

  3. Matt Kruse

    Matt Kruse Guest

    "andy johnson" <> wrote:
    > From what I understand about the design philosophy of Opera, that is
    > so you won't pop up another annoying pop up in someones face. Cruising
    > the Opera forums, newsgroups, KB and bug reports will tell you for
    > sure.


    unfortunately, I can't find any mention of this anywhere. I'm still
    looking...
    I think the correct behavior should be, if my script created the window,
    then my script should be able to check if it's closed, regardless of what is
    being displayed in it at the time.

    Mozilla used to have this same bug, and they fixed it to let .closed be
    visible to any code, regardless of security.

    > From a users point of view, Opera is pretty good, and definitely
    > a good alternative to the crap microsoft puts out.


    It's all a metter of personal preferences. I've disliked every version of
    Opera I've tried, and I've liked IE since version 5. I've been testing and
    using browsers since mosaic came out, and I think IE6 is the best of any one
    I've seen :)

    Matt
    Matt Kruse, Sep 8, 2003
    #3
  4. On Sun, 07 Sep 2003 23:36:03 +0000, Matt Kruse wrote:

    > "andy johnson" <> wrote:
    >> From what I understand about the design philosophy of Opera, that is so
    >> you won't pop up another annoying pop up in someones face. Cruising the
    >> Opera forums, newsgroups, KB and bug reports will tell you for sure.

    >
    > unfortunately, I can't find any mention of this anywhere. I'm still
    > looking...
    > I think the correct behavior should be, if my script created the window,
    > then my script should be able to check if it's closed, regardless of
    > what is being displayed in it at the time.
    >
    > Mozilla used to have this same bug, and they fixed it to let .closed be
    > visible to any code, regardless of security.
    >
    >> From a users point of view, Opera is pretty good, and definitely a good
    >> alternative to the crap microsoft puts out.

    >
    > It's all a metter of personal preferences. I've disliked every version
    > of Opera I've tried, and I've liked IE since version 5. I've been
    > testing and using browsers since mosaic came out, and I think IE6 is the
    > best of any one I've seen :)
    >
    > Matt


    Hi Matt

    I am no expert here, just learning the language but remember an exercise I
    did in my book on this subject. Here is the full code of the exercise, it
    creates a window then takes care of all browsers and how to check if the
    window has been closed by either the code or the user, if the window has
    been closed it will open the same window then close it again, then there
    are no errors. Take a look it might help, you might be able to adapt some
    of it to your advantage.

    Hope it helps
    DaveG


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"> <HTML>
    <HEAD>
    <TITLE>window.closed Property</TITLE> <SCRIPT LANGUAGE="JavaScript">
    // initialise global var for new window object // so it can be accessed
    by all funtions on the page. var newWind

    // set flag to help out with special handling for window closing var
    isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false

    // make new window and put some stuff in it. function newWindow() {
    var output = ""
    newWind = window.open("", "subwindow", "HEIGHT=200, WIDTH=200")

    // taking care of navigator 2
    if (newWind.opener == null) {
    newWind.openern = window
    }
    }
    output += "<HTML><BODY><H1>A sub-window</H1>" output += "<FORM><INPUT
    TYPE='button' VALUE='Close Main Window'
    onClick='window.opener.close()'></FORM></BODY></HTML>"
    newWind.document.write(output)
    newWind.document.close()


    }
    // close subwindow, including ugly workaround for IE3 function
    closeWindow() {
    if (isIE3) {
    // if window is already open, nothing appears to happen // but if not,
    the subwndow flashes momentarily (ahhh) newWind = window.open("",
    "subwindow", "HEIGHT=200, WIDTH=200")
    }
    if (newWind && !newWind.closed) {
    newWind.close()
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM>
    <INPUT TYPE="button" VALUE="Open Window" onClick="newWindow()"><BR>
    <INPUT TYPE="button" VALUE="Close it if still open"
    onClick="closeWindow()">
    </FORM>
    </BODY>
    </HTML>
    Dave Griffiths, Sep 8, 2003
    #4
  5. Matt Kruse

    Matt Kruse Guest

    "Dave Griffiths" <> wrote:
    > I am no expert here, just learning the language but remember an exercise I
    > did in my book on this subject. Here is the full code of the exercise
    > ...
    > if (newWind && !newWind.closed) {
    > newWind.close()
    > }


    This is basically exactly what I'm doing, and what fails in Opera7, when the
    domain of the popped up window is not the same as the opener.
    :(

    Matt Kruse
    Matt Kruse, Sep 9, 2003
    #5
  6. "Matt Kruse" <> wrote in message
    news:6I97b.394629$YN5.261425@sccrnsc01...
    <snip>
    >This is basically exactly what I'm doing, and what fails in Opera7,

    when
    >the domain of the popped up window is not the same as the opener.


    In theory, one horrible hackish quick fix would be to have the pop-up
    load a frameset page form your domain and then have that frameset load
    the page from the other domain. That should leave the new window object
    accessible to your scripts.

    Given the choice I would go for loosing the pop-up in preference.

    Richard.
    Richard Cornford, Sep 9, 2003
    #6
    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. BGS
    Replies:
    0
    Views:
    1,114
  2. =?Utf-8?B?R2FyeQ==?=
    Replies:
    1
    Views:
    500
    =?Utf-8?B?R2FyeQ==?=
    Nov 11, 2005
  3. Bob
    Replies:
    24
    Views:
    1,515
  4. janne
    Replies:
    0
    Views:
    172
    janne
    Aug 20, 2003
  5. PC HUA
    Replies:
    2
    Views:
    390
    PC HUA
    May 19, 2004
Loading...

Share This Page