点击返回时返回页面顶部
我有以下问题:
在此页面上 http://www.projectyou.gr/ gp/?page_id=5 有 3 个选项卡
[全是希腊语,但我希望你能理解]
每个选项卡都包含文章链接。
当您单击一篇文章然后按浏览器上的后退按钮时,它会返回 到选定的选项卡并滚动到您单击的文章。
尽管我很喜欢这种行为,但这并不是我想要的。
我希望用户在返回页面时始终转到顶部。
实现这一目标的最佳方法是什么。
这是否与我使用 jQuery 选项卡和我拥有的代码有关 返回到先前选择的选项卡会导致跳转到先前单击的锚点?
任何帮助将非常感激。
谢谢
I have the following question/problem:
On this page http://www.projectyou.gr/gp/?page_id=5 there are 3 tabs
[It's all in Greek but I hope you will understand]
Each tab contains links to articles.
When you click on an article and then press the back button on the browser it comes back
to the selected tab AND scrolls to the article you clicked.
As much as I like this behavior it is not what I want in this case.
I would like the user, when returning to the page, always go to the top.
What is the best way to achieve this.
Does it have to do with the fact that I'm using jQuery tabs and the code that I have
for returning to the previously selected tab causes to jump to previously clicked anchor??
Any help would be very much appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何将诸如此类的内容添加到您的文档就绪处理程序中(我意识到您可能已经有一个,因此只需附加scrollTo就可以做到这一点):
就像这样 所以问题
how about adding something such as this to your document ready handler (I realize you may already have one, so just appending the scrollTo might do it):
like in this SO question
您还可以使用
以动画方式滚动它,
500 是以毫秒为单位的速度,
0 是从页面顶部开始的距离,
如果你想滚动到某个元素的顶部,你可以将其替换为
;
You could also use
which scrolls it in an animated way,
The 500 is the speed in milliseconds
the 0 is how from from the top of the page,
if you wanted to scroll to the top of an element you could replace it with
;