Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>FireFox doesn't recognize history.go(-1)

FireFox doesn't recognize history.go(-1)

RetiredGeek
02-04-2005, 12:41 AM
I can't seem to get Firefox to work with some code that works fine in IE and as far as I can tell is standard javascript.
<script type="text/javascript">
<!-- Hide from old browsers
function goHist(a)
{
history.go(a); // Go back one.
}
// -->
</script>

<Table width="100%">
<TR>
<TD width="50%"><center>
<a href=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/"#" onClick="goHist(-1)"><img border="0" width="128" height="25"
src=http://www.codingforums.com/archive/index.php/"images/backbtn.gif" alt="Previous"></a></center>
</TD>
<TD width="50%"><center>
<a href=http://www.codingforums.com/archive/index.php/"index.html"><img border=0 width=128 height=25
src=http://www.codingforums.com/archive/index.php/"images/homebtn.gif" alt="Home"></a></center>
</TD>
</TR>
</Table>

If you would like to test the code in the different browsers go to http://www.clarendonhistory.com
then click on 2005 Events and select the Beard Contest.
You can also get there by clicking on the Calendar then changing it to April and clicking on the Beard Contest from there, that's why I need the ambigious back button.
Try it in IE and then Firefox, in Firefox it just stays on the same page. Although I've found that if I do a series of reloads on the page it will eventually go back to the calling page. :(

All assistance greatly appreciated! :)

rmedek
02-04-2005, 12:49 AM
Perhaps <a href=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/"#" onClick="goHist(-1); return false;">?
I don't know anything about JS but this one seemed a bit obvious...

RetiredGeek
02-04-2005, 12:58 AM
Richard, :)
Thanks much you fixed it. Nice job for someone who doesn't know much about js. Could you tell me why this fixed it and why it wasn't necessary for IE? :thumbsup:

_Aerospace_Eng_
02-04-2005, 01:00 AM
i'll tell u y cuz IE is wrong most of the time, FF use semantics so it kept going to the href instead which was a pound sign, the return false tells the browser to ignore the href, hence y it worked after u put return false try it, without return false look at the address bar, the # is being added to the url

RetiredGeek
02-04-2005, 01:06 AM
Aerospace Eng.

Thanks for the enlightenment. :thumbsup:

rmedek
02-04-2005, 01:08 AM
Hey, my first ever helpful javascript post :)

Well, "return false" tells the browser to not do what it was normally going to do before you interrupted it w/ javascript. So this:

<a href=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/"#" onClick="goHist(-1)">...</a>

told the browser to go to http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/"#" and execute the function goHist() when the link was clicked. But this:

<a href=http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/http://www.codingforums.com/archive/index.php/"#" onClick="goHist(-1); return false;">

tells the browser "if this Javascript bit works, don't do what you were going to do. Just do the JS thing."

It worked in IE because IE is a blight on this world and all others. :D

beat me to it! :)


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

write to an html file dynamically?
Changing e.keyCode (e.which)
Clearing a range created by element.createTextRange()
UPDATE: My mouse over pop up question
I am having problem with this script!!!
Creating Handlers
"Login ID" pass over to subsequent pages visited
Checkbox to manipulate Form Field

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics