PDA

View Full Version : window.opener <- the object doesn't exist


cachimba
12-20-2002, 12:30 PM
hi! this is my first post here!
i think that it is a very good site in it's category!

well, i open a window with window.open(), for security, when the opens window is loaded, it test the window.opener object for the parent location is correct.
but if i write the URL of the forced "child" window directly in the explorer, the "opener" object doesn't exist, here is aportion of code:


...
<body onload="javascript:
if (window.opener.location.pathname.search('favoppal.asp')!=-1 &&
window.opener.location.pathname.search('favo.asp')!=-1){ self.location.replace('favo.asp?fallo=true'); }
...


¿¿¿how i can test if an object exists???

thank you very much!

ah, did you visit www.emotimail.tk (http://www.emotimail.tk) :o

allida77
12-20-2002, 02:21 PM
I do a "global" var in my js

var win1 = null

Then when I open a window I do
function openWin{
win1 =open()
}

Then whenever you do any kind of work with the window just test for win1

if (win1) {
code to mess with the popup window
}

cachimba
12-20-2002, 04:53 PM
ok thanks allida77, i'll try it