Reputation: 8913
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
Upvotes: 1
Views: 9365
Reputation: 32119
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.
Upvotes: 1