Web Hosting Talk







View Full Version : simple javascript window linking question


mudley
09-24-2002, 02:25 PM
how can i code a link on a popupped page so it closes itself, and opens the link in the window that originally opened the popup?

i've seen it done before, but can't seem to find an exact example (if i could find one, i'd just 'borrow' the code)

please help

EricP
09-24-2002, 03:50 PM
Within the original window:

<script language="JavaScript">
<!--
function newWindow(file,window) {
msgWindow=open(file,window,'resizable=no,width=200,height=200');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//-->
</script>

<a href="javascript:;" onClick="newWindow('open2.htm','window2')">Open New Window</a>





Within the new window:

<script language="JavaScript">
<!--
function load(file,target) {
if (target != '')
target.window.location.href = file;
else
window.location.href = file;
window.close();
}
//-->
</script>


<a href="javascript:load('http://www.google.com',top.opener)">load document in to opener and close this window</a>

mudley
09-25-2002, 09:27 AM
Thank you soooo much
i'm a javascript 'tard :o

Ultravox
09-26-2002, 12:14 PM
Good script there EricP.