views:

1541

answers:

2

Hi All I have a button on click of which I want to go one step back using javascript. for this I am using window.history.go although this works fine in IE7 and firefox it is not working in IE6 and there is no change as the user stays on the same page.

I m attaching the event to LinkButton

+1  A: 

Use history.back()

Bhushan
this dosent work too for IE6
Vinay Pandey
+1  A: 

IE6 has trouble with window.history.go(). It works on regular links like this:

 <a href='#' onclick='history.go(-1);'>Back!</a>

But some others won't work. You could try this:

 <button onclick='history.go(-1);'>Back!</button>

But I'm not quite sure if that would work. You could also show a button for all other browsers and a link for IE:

 <button id='backButton' onclick='history.go(-1);'>Back!</button>
 <!--[if IE 6]>
 <script type='text/javascript'> document.getElementById('backButton').style.display = 'none'; </script>
 <a href='#' onclick='history.go(-1);'>Back!</a>
 <![endif]-->

It would offcourse be better to add the behaviout in a seperate javascript file instead of inline in the HTML. But I think you get the idea.

Pim Jager
"history.back(); return false;" works brilliant thanx for your answere
Vinay Pandey