Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to emulate browser back button using javascript [duplicate]

Possible Duplicate:
Page history - back button exists?

I need to have a link in some pages of a website, by clicking on it, it needs to go back to the previous page, just like the browser's back button. What is the right way to do that? I'm thinking that I should use some client side scripting like Javascript, right?

like image 211
mahsa.teimourikia Avatar asked Nov 21 '12 09:11

mahsa.teimourikia


2 Answers

In JavaScript, it's:

history.go(-1);

or

history.back();
like image 181
T.J. Crowder Avatar answered Oct 13 '22 07:10

T.J. Crowder


Just use

history.go(-1);

But you cannot go forward anymore after that (so the Forward button doesn't bring you back to where you were -- i.e., this is not 100% the same as clicking the Back button).

like image 30
Roy Dictus Avatar answered Oct 13 '22 06:10

Roy Dictus