...

View Full Version : Back button works in IE7 but not FF 3.01



AmmO
07-30-2008, 10:30 AM
The problem that I'm having is with a back button on my page that uses JavaScript to go back through a browsers history it works fine with IE but doesn't in FF (first time i thought I say that). What happens in FF is it tries to load the previous page but then something overrides it. heres my code


function backUp()
{
if(getValue())
{
history.go(-2);
}
else
{
history.go(-1);
}
}


The getValue is a variable im using in a search function to find a specific page

AmmO
07-30-2008, 10:38 AM
oh and if i didn't mention it im new to javascript and a intermediate html/css user

Philip M
07-30-2008, 10:48 AM
Try this:-


function backUp() {
if(getValue()) {
history.go(-2);
return false;
}
else {
history.go(-1);
return false;
}
}

or


<a href="javascript:void(0);" onclick="history.back(); return false;">Back</a>


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

AmmO
07-30-2008, 10:53 AM
Nope that didn't solve it FF still wont go back but it works fine with IE

AmmO
07-30-2008, 11:14 AM
heres how im calling the scipt for my button


<span class="home" onclick="backUp()"><a href="#">Back</a></span>

AmmO
07-30-2008, 01:07 PM
problem solved found that it was how the java scrip was being called not my original script



<span class="home" onclick="backUp()"><a href="#">Back</a></span>


The problem was when you clicked on the back button it was using going to the href link before the JavaScript could be called.

The functioning code looks like this


<span class="home" onclick="backUp()"><a href="javascript: backUp();">Back</a></span>

AmmO
07-30-2008, 01:18 PM
alteration to the code the last one was jumping back 2 pages because it was being called twice



<span class="home"><a href="javascript: backUp();">Back</a></span>


this is the fully functioning script. Lucky for me our lead coder made it back into work or i dont think id have cracked this myself

Mikebert4
08-01-2008, 05:23 PM
*flex*



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum