Click to See Complete Forum and Search --> : Opened a child window, how can I link back to parent?
wowzer
10-14-2003, 12:22 PM
I used javascript to open a new window.
Now in that new window, I would like to have a "back" link that will take me back to the main webpage - not open a new window, not open the main page in the new window that the link is in, but return to the window with the main page that the child window came from.
-wowzer (newbie)
Khalid Ali
10-14-2003, 12:29 PM
did u mena to close the chhild window???
self.close();
will do
to access parnt window
top.opener.document......
will allow you to access aprent windows document.
jbergthorson
10-14-2003, 12:34 PM
by naming the main window, you should be able to access it that way.
in your main page put:
<html>
<head>
<script language="javascript">
function setName(){
window.name="MyMain"
}
</script>
</head>
<body onLoad="setName()">
blah blah
</body>
<html>
Then you can do
<a href="MyMain.html" target="MyMain" onClick="javascipt:window.close();">Back</a>
in your popup window as your back link
Hope that helps
jason
wowzer
10-14-2003, 12:35 PM
No, the child should stay open (all my children close when the main page is closed.
Sorry, I don't understand what to do with the other part, but it does sound like what I'm trying to do:
to access parent window
top.opener.document......
will allow you to access parent windows document.
Thanks for your help.
Khalid Ali
10-14-2003, 12:39 PM
suppose you had a form in the parent window by name="parentForm"
and it had a text field name ="firstName"
and you wanted to pouplate it from the child window
top.opener.document.parentForm.firstName.value="Khalid"
will put the name in the parent window text field from child window
jbergthorson
10-14-2003, 12:41 PM
oh i just noticed khalid beat me to your requested solution ;)
Using top.opener.document.href="blah.html" is actually maybe a shorter way of doing it, dependant on how your windows are opened and such. But if it is not the parent window that you want to change, then i find it easier to do the naming thing than trying to access the window through a bunch of pointers. Say for example, some window opens a popup window who opens a popup window who opens another popup window. Then trying to access a specific window is a real headache, well at least for my brain! I have a hard time keeping track of more than 3 windows at a time ;)
jason
wowzer
10-14-2003, 12:45 PM
Thanks guys, I'll go play with it now!
Khalid Ali
10-14-2003, 01:01 PM
glad to be of help..:)