在我页面的页脚中,有一些链接使用锚标记指向同一页面上不同部分的链接(在页面URL上附加#)。
In the footer of my page there a few links that point to different sections on the same page using anchor tags (# appended to the URL of the page).
这很好,只是浏览器后退按钮不起作用:我无法从导航到锚定页面的位置移回上一页。
This works fine, just the browser back button does not work: I cannot move back to the previous page from where I had navigated to the anchored page.
简单的问题在这里,在锚定页面中浏览几次后是否可以返回上一页?
The simple question here is, is it possible to move back to previous page after navigating in the anchored page a few times? If it is then please could you suggest how?
锚定页面:该页面具有由id属性标记的多个部分,该页面可以由带有 #anchorId 最后。
Anchored page: the page that has several sections marked by the id attribute that can be pointed to by a URL with #anchorId at the end.
推荐答案我也遇到了同样的问题,请参阅我的问题锚定链接指向页面部分无法在浏览器上进行刷新,前进和后退
I also faced the same problem see my question anchor links referring to the page sections not working on browser refresh, back and forward
但是我必须按照正常链接的工作方式进行操作,所以我要做的是手动转到
But I had to do it the way normal links work so what I did was I manually go to that section by getting the element from the hash.
$(window).on('hashchange', function () { var top = $(window.location.hash).offset().top; $(window).scrollTop(top); });此功能适用于前进和后退按钮。 为了刷新,您还需要执行相同的操作。从哈希中获取元素,然后手动滚动到该元素。
This works for forward and back buttons. And for refresh also you need to do the same thing. Get the element from the hash and scroll to that element manually.
更多推荐
浏览器后退按钮不适用于锚链接
发布评论