简体   繁体   English

单击浏览器的“后退”按钮时,返回上一页的上一个位置

[英]Go Back to the Previous Location on Previous Page when Clicking Browser Back Button

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. 在页面a上,单击链接,转到页面b,从头开始显示页面b上的所有内容。 Click browser back button, it goes back to page a and showing contents from the link position. 单击浏览器后退按钮,它将返回到页面a并显示链接位置的内容。

This is what I got now: 这就是我现在得到的:

It happens between two aspx pages, 它发生在两个aspx页面之间,

1、On the first page, http://xxxx/default.aspx#project/page/home , there is a link < a href="#page/test" >TEST< / a > 1,在第一页http://xxxx/default.aspx#project/page/home上 ,有一个链接<a href =“#page / test”>测试</ / a>

2、So When I click this link, it will jump to http://xxxx/default.aspx#project/page/test . 2,因此,当我单击此链接时,它将跳至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. 3,当我单击浏览器后退按钮时,回到上一页,也无法返回到该链接位置。

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. 附加信息:我将<a href =“#page / test”> TEST </a>更改为<a href =“ https://stackoverflow.com/questions/1215449/browser-does-not-remember-position- of-page-last-viewed“> TEST </ a>,效果很好。 So I think it is because of the aspx pages and the hashtag. 所以我认为这是因为aspx页面和#标签。

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. 请帮忙,谢谢。

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: 要使用<a>标记重新定位页面,您需要具有一个id属性与链接中#之后的文本匹配的元素:

<!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: 在HTML5之前,这是通过另一个包含name属性的<a>完成的:

<!DOCTYPE html>
<html>
<body>

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

<p>Text here</p>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我单击浏览器的“后退”按钮时,它应该转到同一页面的上一个活动 - when I clicking on Back button of browser , it should go to the previous activity of the same page 防止浏览器后退按钮不转到上一页 - Prevent browser back button to not go to previous page 单击浏览器后退按钮时如何转到当前页面的上一页 - How to go previous page of current page , while clicking browser back button 单击浏览器后退按钮时,将用户带回上一页滚动到的位置 - Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button 即使更改了哈希值,如何在网页中单击浏览器后退按钮时返回上一页? - How to go back to the previous page when browser back button is clicked in a webpage even when the hash is changed? 当按下浏览器后退按钮(在 Javascript 中)时,如何将特定变量传递给 go 返回上一页? - How to pass a specific variable to go back to the previous page when the browser back button is pressed (In Javascript)? 不允许将CSS携带到上一页(单击浏览器后退按钮后) - Not allowing CSS to be carried to previous page (after clicking browser back button) 我需要使用浏览器按钮返回上一个动态页面 - I need to use the browser button to go back to the previous dynamic page 返回上一页 - Go Back to Previous Page 通过单击后退按钮重新加载上一页 - Reload the previous page by clicking the back button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM