opener.opener ?

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

    #1

    opener.opener ?

    Hi,

    I have window A, which open popup A which Open popup C.

    In the two popups I use a common JavaScript file and in order to
    distinguish between them I use the following code:


    if (typeof(opener. opener)=="objec t") {
    alert("1");
    }
    else if (typeof(opener) =="object") {
    alert("2");
    }

    The problem is that I get "1" for both popups.
    I.e. "opener.ope ner" exists also for popup A.


    Any ideas ?

    Thanks,
    Yaron
  • Thomas 'PointedEars' Lahn

    #2
    Re: opener.opener ?

    Yaron C. wrote:
    [color=blue]
    > I have window A, which open popup A which Open popup C.
    >
    > In the two popups I use a common JavaScript file and in order to
    > distinguish between them I use the following code:
    >
    >
    > if (typeof(opener. opener)=="objec t") {
    > alert("1");
    > }
    > else if (typeof(opener) =="object") {
    > alert("2");
    > }
    >
    > The problem is that I get "1" for both popups.
    > I.e. "opener.ope ner" exists also for popup A.[/color]

    AFAIS, the value of the `opener' property for a window not opened by another
    window with client-side scripting is `null' which explains why you still get
    `object' for its type (see the discussion a week or so ago).[1]
    So

    if (typeof opener != "undefined" && opener)
    {
    ...
    }

    should suffice since `null' evaluates to `false' in a boolean expression.
    More simple, but assuming that `opener' is a property of window, is

    if (window.opener)
    {
    ...
    }


    HTH

    PointedEars
    ___________
    [1] Suprisingly, alert(opener) then shows an "empty" message box, while
    alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
    Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: opener.opener ?

      Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
      [color=blue]
      > [1] Suprisingly, alert(opener) then shows an "empty" message box, while
      > alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
      > Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.[/color]

      Yes, it seems that in Mozilla
      alert(null)
      creates an empty alert (just as the empty string), while
      alert(String(nu ll))
      ofcourse alerts the string "null".

      In IE and Opera, alert(null) alerts the string "null", while alert()
      gives the empty alert. Mozilla doesn't allow alert().

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: opener.opener ?

        Lasse Reichstein Nielsen wrote:
        [color=blue]
        > Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:[color=green]
        >> [1] Suprisingly, alert(opener) then shows an "empty" message box, while
        >> alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
        >> Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.[/color]
        >
        > Yes, it seems that in Mozilla
        > alert(null)
        > creates an empty alert (just as the empty string), while
        > alert(String(nu ll))
        > ofcourse alerts the string "null".
        >
        > In IE and Opera, alert(null) alerts the string "null", while alert()
        > gives the empty alert. Mozilla doesn't allow alert().[/color]

        It is not an alert(...) issue since assigning `null' to the `value'
        property of an HTMLTextArea object and then retrieving it without
        alert(...) (namely assigning its value to it) also shows the empty
        string, while assigning `String(null)' shows `null'.


        PointedEars

        Comment

        • Yaron C.

          #5
          Re: opener.opener ?

          Thanks !

          Thomas 'PointedEars' Lahn <PointedEars@we b.de> wrote in message news:<3FA1808A. 1030002@Pointed Ears.de>...[color=blue]
          > Lasse Reichstein Nielsen wrote:
          >[color=green]
          > > Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:[color=darkred]
          > >> [1] Suprisingly, alert(opener) then shows an "empty" message box, while
          > >> alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
          > >> Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.[/color]
          > >
          > > Yes, it seems that in Mozilla
          > > alert(null)
          > > creates an empty alert (just as the empty string), while
          > > alert(String(nu ll))
          > > ofcourse alerts the string "null".
          > >
          > > In IE and Opera, alert(null) alerts the string "null", while alert()
          > > gives the empty alert. Mozilla doesn't allow alert().[/color]
          >
          > It is not an alert(...) issue since assigning `null' to the `value'
          > property of an HTMLTextArea object and then retrieving it without
          > alert(...) (namely assigning its value to it) also shows the empty
          > string, while assigning `String(null)' shows `null'.
          >
          >
          > PointedEars[/color]

          Comment

          Working...