Click to See Complete Forum and Search --> : Naming the Main Window in Netscape?


virgil
03-14-2003, 09:02 AM
Hi

I'm having a hell of a time tring to get the "main"(first initial window) in Netscape to reload from another JS opened window.

I used...

<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

self.name = "main";

//-->
</SCRIPT>
</head>

..in a framepage. Then from a new window...

<a href='http://www.my_site.com/frame_page.php?info=$info' onclick='window.close()' target='main'>link</a>


...and it works perfectly in Internet Explorer.


But, Netscape closes the new window and never reloads the initial window.


Any advice at all would be most appreciated. :) :)



Virgil

requestcode
03-14-2003, 09:13 AM
To refer to the initial window use the "opener" property. You could change you link to this:
<a href='http://www.my_site.com/frame_page.php?info=$info' onclick='opener.window.close()'>link</a>

This should work in both IE and NS. Of course you will get the warning when closing the "opener" window, nothing you can do about that.

virgil
03-14-2003, 10:16 AM
Thanks for the post ,but I need to "target" the opener, not close it.

I think I need to name the "opener" window so I can reference it in the Target="frame_name" Att.

window.close is to close the "new" window behind me as I send url data from the "new" window to the opener window.



Unless my logic is off. Which is not too unusual:)


Thanks Virgil

gil davis
03-14-2003, 10:32 AM
Originally posted by virgil
<a href='http://www.my_site.com/frame_page.php?info=$info' onclick='window.close()' target='main'>link</a>
...
But, Netscape closes the new window and never reloads the initial window.It's just doing what you asked it to do. You cannot expect code that follows a window.close() command to run consistently. It's sort of like getting out of a car moving at 60 MPH and then trying to hit the brakes. NS rightfully does the onclick before it does the href action. It would be safer if you were to use setTimeout() to close the window.<a href='http://www.my_site.com/frame_page.php?info=$info' onclick="setTimeout('window.close()',500)" target='main'>link</a>

virgil
03-14-2003, 11:27 AM
That did it!

I should have removed the onclick='window.close' to begin with as a test.

MOST GRACIOUS THANKS :) :) :)

Virgil