View Full Version : History back problem
Hi team,
I have a little problem effecting IE browsers only.
I'm working on a script for a friend, it opens a new pop up window that contains some navigation links to other sites. These links open in the parent browser window but the problem is that he wants it to be able to make the parent window go back one in history.
The script I have is:
<a href="javascript:parent.opener.history.back(1)">Back 1</a>
This works fine in Netscape, but does nothing in IE, does anyone have a correction to make this work in IE and NS browsers. I've tried several other methods, but none have been sucessful in IE.
cheers for any solution.
whkoh
09-10-2001, 06:15 AM
What about <a href="#" onClick="javascript:parent.history.go(-1)">Back</a>
Nope sorry, that doesn't work in IE or NS.
pixelmonkey
09-10-2001, 01:30 PM
<a href="javascript:history.back(1)">back</a>
does that work with NN though?
chris<pixelmonkey>:monkey:
_mrkite
09-10-2001, 01:48 PM
parent generally references frames; opener is for popup spawners. Have you tried:
<a href="#" onclick="opener.history.go(-1);return false;">Back 1</a>
opener.history.go(1) simulates the forward button...
scoutt
09-10-2001, 02:34 PM
what about
onClick="history.go(-1)"
Dr. Web
09-10-2001, 02:49 PM
Originally posted by Ian
the problem is that he wants it to be able to make the parent window go back one in history.
he wants the PARENT to go back one....
Dr. Web
09-10-2001, 03:03 PM
hey Ian, try something like _mrkite suggested:
parent page:
<html>
<head>
<title>Untitled</title>
<script language ="javascript">
function pop_up(){
win = window.open("childSaysParentBack.htm", "dep", statusbar="yes","height=100,width=200", hotkeys="no");
}
</script>
</head>
<body >
<a href="#" onClick="pop_up()">child window</a>
</body>
</html>
spawned page:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<br><br>
<a href="#" onclick="javascript: window.opener.history.go(-1)">Parent back button</a>
</body>
</html>
though hsitory.go(1) failed to move the page forward in this case.
cloud9
09-10-2001, 03:10 PM
c9 :D
parent.opener.history.back(1)
? why not do something like this:
in the window you want to change the history have this:
function goback{) {
history.back(1)
}
then call it like
opener.goback()
or similar, this should work if you get the syntax right:D
scoutt
09-10-2001, 06:03 PM
Originally posted by Dr. Web
he wants the PARENT to go back one....
I was going off that he had the go back link in the parent window. I wasn't sure if the link was in the popup window or not.
Dr. Web
09-10-2001, 07:09 PM
I see. I was a bit conf-rused the first time too!
Sorry, ya, the link is in the pop up window to make the main window go back one. I have tried Doc's, and _mrkite's, both do not work. :(
Adition...
Here is the current pop up window contents. (which opens 150x400)
<head>
<title>More Search Engines</title>
<script>
function remote(url){
window.opener.location=url
}
</script>
</head>
<body text="#000000" bgcolor="#CC66CC" link="#FFFFFF" vlink="#3333FF" alink="#000099">
<center><b><font face="Arial,Helvetica"><font color="#FFFFFF">More Search
Engines</font></font></b></center>
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH="95%" >
<tr>
<td ALIGN=LEFT><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.exite.com/' )">Exite</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.mamma.com/' )">Mamma</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.altavista.com/' )">Alta
Vista</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.infoseek.com/' )">Infoseek</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.looksmart.com/' )">LookSmart</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.lycos.com/' )">Lycos</a></font></font></font></u></b>
<br><b><u><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><a href="javascript: remote( 'http://www.snap.com/' )">Snap</a></font></font></font></u></b></td>
</tr>
</table></center>
<center>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-2>These
links will open in your main browser window.</font></font></font></center>
<br>
<br>
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH="95%" >
<tr>
<td><b><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><
<a href="javascript:parent.opener.history.back(1);return false;">Back 1</a></font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1><<
<a href="javascript: remote( 'http://www.home.com' )">Back
Home</a></font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>
<a href="javascript:window.close()">Close This</a></font></font></font></b><br>
</td>
</tr>
</table></center>
</body>
Thanks to all who are trying to nut this out with me, it is much appreciated.
Jon Hanlon
09-10-2001, 07:44 PM
_mrkite is right - 'parent' is used in frames and is a reference to the window containing the frameset tag corresponding to the current window, whereas 'opener' is a reference to the window that created the current window.
You don't want 'parent'.
Dr. Web's solution is correct.
There is one little hiccup however - if the history.go() method navigates off to another domain, then the browser's security model will prevent the link from working. In other words, you could use the 'Opener Go Back' link once, but after that it's not guaranteed to work. Maybe you should close the pop-up window after they've gone back the first time.
Originally posted by jonhanlon
[B
There is one little hiccup however - if the history.go() method navigates off to another domain, then the browser's security model will prevent the link from working[/B]Jon, Thanks, I think you hit the nail on the head there. The above script I have posted works fine in NS, it just may be an IE problem and may not be able to be made to work.:(
Dr. Web
09-11-2001, 12:07 PM
IAN,
my method works in Netscape4.7 and IE5.0/ 5.5 BUT you need to hit the back button TWICE. Try changing history.go(-1) to -2
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.