browsers' differences in action on same code.

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

    browsers' differences in action on same code.

    This code works perfectly in IExplorer, but in exactly the same context
    does not work at all in Netscape 7.x.

    <SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
    <!--
    if (window.parent. opener.closed)
    {
    window.parent.c lose();
    };
    // -->
    </SCRIPT>

    This is intended to detect the presence of an open parent window. When
    one closes the open parent in IE, the child closes promply. In Netscape,
    the inner loop is apparently not executed after the window is closed.
    Reversing the logic on the opener test works fine as long as the window
    is open. But, hey! Isn't ...opener.close d supposed to return something
    if a window is closed? It seems to simply... fail. The inner loop will
    not execute with either a negative or positive logic spin (!window...).

    --
    *************** *************** *****
    * Bob Dickow (dickow@uidaho. edu) *
    * Hampton School of Music *
    *************** *************** *****
  • Thomas 'PointedEars' Lahn

    #2
    Re: browsers' differences in action on same code.

    Robert Dickow wrote:
    [color=blue]
    > This code works perfectly in IExplorer,[/color]

    Sure? Maybe you have disabled the display of script errors.
    [color=blue]
    > <SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
    > <!--
    > if (window.parent. opener.closed)
    > {
    > window.parent.c lose();
    > };
    > // -->
    > </SCRIPT>
    >
    > This is intended to detect the presence of an open parent window. When
    > one closes the open parent in IE, the child closes promply.[/color]

    Where is the event that triggers the above code?
    [color=blue]
    > In Netscape, the inner loop is apparently not executed[/color]

    There is no (`if') loop! `if' is a conditional statement
    and you defined a block of statements with `{...}' to be
    executed if it evaluates to `true'.
    [color=blue]
    > after the window is closed.[/color]

    Try

    function foobar()
    {
    if (window.parent
    && window.parent.c lose
    && (!window.parent .opener || window.parent.o pener.closed))
    window.parent.c lose();
    }

    and use the `unonload' event handler of the `body' element to call that
    function. Note that the event also fires when the user displays another
    document in the same window.


    PointedEars

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: browsers' differences in action on same code.

      (Have canceled my other posting, please consider it obsolete.)

      Robert Dickow wrote:
      [color=blue]
      > This code works perfectly in IExplorer,[/color]

      Sure? Maybe you have disabled the display of script errors.
      [color=blue]
      > <SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
      > <!--
      > if (window.parent. opener.closed)
      > {
      > window.parent.c lose();
      > };
      > // -->
      > </SCRIPT>
      >
      > This is intended to detect the presence of an open parent window. When
      > one closes the open parent in IE, the child closes promply.[/color]

      Where is the event that triggers the above code?
      [color=blue]
      > In Netscape, the inner loop is apparently not executed[/color]

      There is no (`if') loop! `if' is a conditional statement
      and you defined a block of statements with `{...}' to be
      executed if it evaluates to `true'.
      [color=blue]
      > after the window is closed.[/color]

      Try

      function foobar()
      {
      if (window.parent
      && window.parent.c lose
      && !window.parent. closed
      && (!window.parent .opener || window.parent.o pener.closed))
      window.parent.c lose();
      }

      and use the `unonload' event handler of the `body' element to call that
      function. Note that the event also fires when the user displays another
      document in the same window.


      PointedEars

      Comment

      • Michael Winter

        #4
        Re: browsers' differences in action on same code.

        "Robert Dickow" wrote on 11/11/2003:
        [color=blue]
        > This code works perfectly in IExplorer, but in exactly the same[/color]
        context[color=blue]
        > does not work at all in Netscape 7.x.
        >
        > <SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">[/color]

        The 'language' attribute is depreciated in HTML and shouldn't be used.
        You should also realise that "JavaScript " represents v1.0 of the
        language. Netscape probably (read: double check with someone else)
        interprets this religiously and neither 'opener' nor 'closed' were
        introduced until v1.1.
        [color=blue]
        > <!--
        > if (window.parent. opener.closed)
        > {
        > window.parent.c lose();
        > };
        > // -->
        > </SCRIPT>
        >
        > This is intended to detect the presence of an open parent window.[/color]

        I don't believe it does:

        window
        current window
        window.parent
        parent of the current window
        window.parent.o pener
        window that opened (using window.open) the parent of the current
        window
        window.parent.o pener.closed
        true if the window that opened (using window.open) the parent of the
        current window is closed

        Are you sure that you're checking the correct window? You describe the
        parent, not the parent of the parent.
        [color=blue]
        > When
        > one closes the open parent in IE, the child closes promply. In[/color]
        Netscape,[color=blue]
        > the inner loop is apparently not executed after the window is[/color]
        closed.[color=blue]
        > Reversing the logic on the opener test works fine as long as the[/color]
        window[color=blue]
        > is open. But, hey! Isn't ...opener.close d supposed to return[/color]
        something[color=blue]
        > if a window is closed? It seems to simply... fail. The inner loop[/color]
        will[color=blue]
        > not execute with either a negative or positive logic spin[/color]
        (!window...).



        Comment

        • Robert Dickow

          #5
          Re: browsers' differences in action on same code.

          Thanks for the solution! The wonderfully byzantine test clause
          solved the problem for Netscape. Turns out that it does ok
          with the deprecated LANGUAGE="JavaS cript" in this case.

          I don't use a trigger event for this at all; it is in the
          midst of PHP code and it simply passed to the client
          when a certain condition is present. This instantly closes
          the client window.

          Thomas 'PointedEars' Lahn <PointedEars@we b.de> wrote in
          news:boqhv1$1gm 1qf$1@ID-107532.news.uni-berlin.de:
          [color=blue]
          > Robert Dickow wrote:
          >[color=green]
          >> This code works perfectly in IExplorer,[/color]
          >
          > Sure? Maybe you have disabled the display of script errors.
          >[color=green]
          >> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
          >> <!--
          >> if (window.parent. opener.closed)
          >> {
          >> window.parent.c lose();
          >> };
          >> // -->
          >> </SCRIPT>
          >>
          >> This is intended to detect the presence of an open parent window.
          >> When one closes the open parent in IE, the child closes promply.[/color]
          >
          > Where is the event that triggers the above code?
          >[color=green]
          >> In Netscape, the inner loop is apparently not executed[/color]
          >
          > There is no (`if') loop! `if' is a conditional statement
          > and you defined a block of statements with `{...}' to be
          > executed if it evaluates to `true'.
          >[color=green]
          >> after the window is closed.[/color]
          >
          > Try
          >
          > function foobar()
          > {
          > if (window.parent
          > && window.parent.c lose
          > && (!window.parent .opener || window.parent.o pener.closed))
          > window.parent.c lose();
          > }
          >
          > and use the `unonload' event handler of the `body' element to call
          > that <snip>[/color]

          --
          *************** *************** *****
          * Bob Dickow (dickow@uidaho. edu) *
          * Hampton School of Music *
          *************** *************** *****

          Comment

          Working...