Thursday, December 27, 2012

history.back() not working in chrome

I have faced this issue and searched for long time to get a good solution. Instead of using history.back(), use history.go(-1). It is working in IE,Chrome and Firefox. Add return false also to the function


example:
 <html>  
 <head>  
 <script>  
 function goBack()  
 {  
   window.history.go(-1);  
   return false;  
  }  
 </script>  
 </head>  
 <body>  
    <input type="button" value="Back" onclick="goBack()">  
 </body>  
 </html>  

No comments:

Post a Comment