问题描述
页面中有一些锚点,当我使用锚点加载页面时:
I have some anchors in the page and when I load page using anchor:
http://localhost:1820/Home/FAQ#question4
jQuery Mobile在1-3秒后会自动滚动到页面顶部.我无法为$(document).ready()
添加修复程序,因为此事件在滚动之前触发(滚动加载在所有内容加载后显示-带有其他社交按钮图像,脚本等).
jQuery Mobile after 1-3 seconds automatically scrolls to top of the page. I cannot add fix to $(document).ready()
because this event fires before scrolling (scrolling appear after all content is loaded - with additional social button images, scripts etc.).
当我删除jquery.mobile-1.1.1.js脚本时-错误消失了.当我删除除jQuery和jQuery mobile以外的所有脚本时,错误仍然存在.因此问题应该出在jQuery Mobile脚本中.
When I removing jquery.mobile-1.1.1.js script - bug disappears.When I removing all scripts except jQuery and jQuery mobile - bug still exists. So the problem should be in jQuery Mobile script.
我该如何解决问题?
我使用Chrome和Opera对其进行了测试.
I used Chrome and Opera to test it.
P.S.我设置了$.mobile.ajaxEnabled = false;
,所以我的网站不使用Ajax加载页面.
P.S. I set $.mobile.ajaxEnabled = false;
, so my site do not use Ajax to load pages.
推荐答案
$.mobile.silentScroll()
可以解决您的问题.您可以在页面加载时捕获哈希"部分,并使用它自动滚动到需要将页面带到的部分.我最近回答了类似的问题.看看是否对您有帮助 jQuery Mobile标签和锚点
Can be a solution to your problems.You can catch the Hash section at page load and use it to automatically scroll to the section where you need to take your page to. I answered a similar question recently. See if it helps youjQuery Mobile Tabs and Anchors
这篇关于如何禁用jQuery Mobile滚动到页面顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!