Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having 3 pages - Page1, Page2 and Page3 where all three has back button with below code.

<a href="#"  önclick="window.history.back(-1);">back</a>


My expectation is when I navigate from Page1 to Page2 then to Page3, it should come back Page3 to Page2 then to Page1. But, It is looping between Page3 and Page2.

Is there any way to solve this issue?
Posted

try this,,,:)


JavaScript
<a href="#" onclick="window.history.go(-1)">back</a> 
 
Share this answer
 
HI,

The most easiest way that you can do is maintain an unique id and navigate the pages as you want to by passing the id by session or query string.

e.g say my page1 contains the is as 1 and followed by the rest of the pages. When I am in the page 3 then the session value will be 3. So on the back button click just change the id to go to the previous page. this is the simplest solution that is striking in my mind.

Thanks
 
Share this answer
 
hi sankar.......

onclick="window.history.go(-1)"

this may also work but there is problem that your browser must have history in this if user type some url directly then there will be a problems

or you have query strings or sessions maintaining last page or redirecting to the particular page

regards...:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900