0

This is what I want to implement:

On page a, click the link, go to page b,showing everything on page b from the beginning. Click browser back button, it goes back to page a and showing contents from the link position.

This is what I got now:

It happens between two aspx pages,

1、On the first page, http://xxxx/default.aspx#project/page/home, there is a link < a href="#page/test" >TEST< / a >

2、So When I click this link, it will jump to http://xxxx/default.aspx#project/page/test. But it seems like the browser remembers the link position on page/home and directly jump to the same position on page/test,instead of showing all the contents from the very beginning.

3、When I click browser back button, to the previous page, it also cannot go back to that link position.

Additional information: I changed the < a href="#page/test" >TEST< / a> to < a href="https://stackoverflow.com/questions/1215449/browser-does-not-remember-position-of-page-last-viewed" >TEST< / a >, it worked just fine. So I think it is because of the aspx pages and the hashtag.

I have tried this, it will cause showing two pages at the same time(one on the left and one on the right) Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button

Please help, thank you.

Community
  • 1
  • 1
Xinyi Shen
  • 1
  • 1
  • 1
  • `http://xxxx/default.aspx#project/page/home` and `http://xxxx/default.aspx#project/page/test` are both the same page - default.aspx – Jen R May 08 '17 at 21:08
  • @JenR, Thank you so much for the reply. Do you happen to know a way to implement what I wanted? even they are one page. – Xinyi Shen May 08 '17 at 21:18

1 Answers1

0

To use an <a> tag to re-position the page, you need to have an element with an id attribute that matches the text following # in the link:

<!DOCTYPE html>
<html>
<body>

<h2 id="thetop">Top of page!</h2>

<p>Text here</p>

<a href="#thetop">Go to top</a>
</body>
</html>

Before HTML5, this was done with another <a> that included a name attribute:

<!DOCTYPE html>
<html>
<body>

<a name="thetop">Top of page!</a>

<p>Text here</p>

<a href="#thetop">Go to top</a>
</body>
</html>
Jen R
  • 1,527
  • 18
  • 23