in popup window, checking if page in opener window - any help?

Discussion in 'Javascript' started by JPL Verhey, Feb 14, 2005.

  1. JPL Verhey

    JPL Verhey Guest

    Hi,

    I have a little test script in a pop up window. The pop up page
    refreshes every 2 seconds. I want it to check with every refresh if a
    certain page (log3.htm) is loaded in the opener window. If that is the
    case, another page (log4.htm) must be loaded in the opener window.

    In pop up page:

    <script>
    <!--
    if (opener.location.href="log3.htm")
    {opener.location.replace("log4.htm")}
    //-->
    </script>

    But it aint working :( What happens is that the condition doesn't work,
    because with *any* page in the opener window, it is replaced immediately
    with log4.htm when the pop up refreshes - log4.htm should only be
    loaded automatically when log3htm is in the opnener window. So pop up
    and opnener parent do communicate.. but just not as I'd like them.
    Anyone??

    *&%$
    Thnx
     
    JPL Verhey, Feb 14, 2005
    #1
    1. Advertising

  2. JPL Verhey

    kaeli Guest

    In article <4210bed5$0$44109$>,
    enlightened us with...
    >>

    > <script>
    > <!--
    > if (opener.location.href="log3.htm")


    Fundamental error.
    =
    ==
    The first assigns.
    The second compares.
    if (opener.location.href=="log3.htm")

    --
    --
    ~kaeli~
    The more ridiculous a belief system, the higher probability
    of its success.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Feb 14, 2005
    #2
    1. Advertising

  3. JPL Verhey wrote:

    > if (opener.location.href="log3.htm")


    The comparison operator is "==", not "=".

    > {opener.location.replace("log4.htm")}


    > with *any* page in the opener window, it is replaced
    > immediately with log4.htm when the pop up refreshes


    The assignment you accidentally typed always evaluates to "true" since
    you assign a string that's not the null string. In addition, the href
    property will most likely contain more than "log3.htm" (protocol,
    hostname, and path info), and you should look if the opener window is
    still there:

    if (
    opener
    && !opener.closed
    && opener.location.replace
    && opener.location.href.match(/log3\.htm$/)
    )
    opener.location.replace("log4.htm");

    ciao, dhgm
     
    Dietmar Meier, Feb 14, 2005
    #3
  4. JPL Verhey

    JPL Verhey Guest

    "kaeli" <> wrote in message
    news:...
    > In article <4210bed5$0$44109$>,
    > enlightened us with...
    >>>

    >> <script>
    >> <!--
    >> if (opener.location.href="log3.htm")

    >
    > Fundamental error.
    > =
    > ==
    > The first assigns.
    > The second compares.
    > if (opener.location.href=="log3.htm")


    Ok thanks! Wasn't aware of that.
     
    JPL Verhey, Feb 14, 2005
    #4
  5. JPL Verhey

    JPL Verhey Guest

    The below works! Brilliant, thanks alot..

    "Dietmar Meier" <> wrote in
    message news:...
    > JPL Verhey wrote:
    >
    >> if (opener.location.href="log3.htm")

    >
    > The comparison operator is "==", not "=".
    >
    >> {opener.location.replace("log4.htm")}

    >
    >> with *any* page in the opener window, it is replaced
    >> immediately with log4.htm when the pop up refreshes

    >
    > The assignment you accidentally typed always evaluates to "true" since
    > you assign a string that's not the null string. In addition, the href
    > property will most likely contain more than "log3.htm" (protocol,
    > hostname, and path info), and you should look if the opener window is
    > still there:
    >
    > if (
    > opener
    > && !opener.closed
    > && opener.location.replace
    > && opener.location.href.match(/log3\.htm$/)
    > )
    > opener.location.replace("log4.htm");
    >
    > ciao, dhgm
     
    JPL Verhey, Feb 14, 2005
    #5
    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. =?Utf-8?B?Sko=?=
    Replies:
    1
    Views:
    2,242
    =?Utf-8?B?dmluYXk=?=
    Oct 12, 2004
  2. Matt Jensen
    Replies:
    1
    Views:
    5,269
    Matt Jensen
    Dec 16, 2005
  3. Urs Gubler
    Replies:
    0
    Views:
    169
    Urs Gubler
    Jul 2, 2003
  4. sentinel
    Replies:
    1
    Views:
    182
    kaeli
    Feb 16, 2004
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    300
Loading...

Share This Page