I have done a few searches for this issue and I have come up empty handed. I hope somebody can clarify things for me and point me in the right direction.
Problem: I have a page that displays a list of results after submitting a search form. When a user clicks on one of the results, the browser goes to a new page showing more information about the result. When the user then clicks the 'back' button to go pack to the results, my browser reloads the page and shows the top of the page instead of the result that was last clicked.
Goal: What I would like is this: when the user click's the back button, the browser should go back to the previous page and, instead of showing the top of the page, show the page at the previous position.
Solution: I am completely lost as how this result can be achieved. Could it have something to do with javascript, or headers sent to the browsers, maybe something to do with caching.
You can use javascript and jquery to set the scroll position of the window and cookies to store the position to scroll to. In the javascript of the page with the search results you could have something like this:
This assumes your search result links have
class="resultLink"
.The first part of the answer is that you use anchors to land on a page somewhere other than the top. So if I have this in my html at the bottom of my page:
then I can have the user land there by appending the anchor to the end of he url:
So, if you are talking about ASP.Net you can place the anchor in a hidden field on the page info page and then read it from the search page by using: Page.PreviousPage property.
If this is incredibly important, I'd suggest investigating the following:
id
s to each outgoing linkonClick
for the linksid
fragment identifier, then link out as desiredWhen the user hits the back button, they'll return to that specific link, e.g.
http://www.example.com/#link27
instead ofhttp://www.example.com/
You may be able to get some ideas from here:
I fixed this issue by sending headers with php. This was my solution:
Thanks to everybody for the help.