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

J

JPL Verhey

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
 
D

Dietmar Meier

JPL said:
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
 
J

JPL Verhey

The below works! Brilliant, thanks alot..

Dietmar Meier said:
The comparison operator is "==", not "=".



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top