Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

child popup is it open?

Status
Not open for further replies.

zapster

Programmer
Jun 8, 2001
36
GB
Hi All

I have to call up some 3rd party javascript to generate a pop-up ("_new"). This pop-up window will only display x in y visits. I know the name of the popup "_new", but I would like to detect when this popup is not generated therefore I can call a different pop-up ("hero").

This is what I have to use for the third party code in my html

document.write('<scr'+'ipt language=&quot;JavaScript&quot; src= + getJSname('$JSname$') + '.js></scr'+'ipt>');

How do I find out it this child &quot;_new&quot; has been created?

Thanks

Zapster
 
varMyWin = window.open('', '_new');

that will give you a handle to the &quot;_new&quot; window if it is already open.Without modifying any of the contents of the child window.
The bad news is that if the &quot;_new&quot; window is not open your users will see a blank page as the popup.

Now this is not as bad as it sounds.
If you are the one controling the parent page and you want to show something different if the contents from your third party provider are not loaded, just check for a value only you would know.
For example check for the location as in varMyWin.location.href if this value is equal to your know domain then you have the secondary page open if not that means you have the contents of your 3d party.

If the child page has been opened by another Parent Window(PW1) and now the Parent Window(PW1) is gone and you use the line of code in another Parent Window(PW2), you most likely get an error message telling you that &quot;permission is denied&quot;. I guess that is the result of The window.opener Property. ( I'm only guessing with this).
Since you are the one opening the file I think you have more control over things.


I hope that helps.
 
I've playing with this for a while.
It seems this works.( I say it seems because I only have IE6.0/win2000 on this computer) I couldn't test it with other config.

<script language=&quot;JavaScript&quot;>
var newWindow=window.open('','_new');
if(newWindow.opener==self)
{alert(&quot;Same Parent&quot;)} else {alert(&quot;Different Parent&quot;)};
</script>

with this code you can check if the &quot;_new&quot; window was opened from the current page or with some other page.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top