我有这个链接:
<a rel="external" href="/feed/123/#comment">comment</a>
当我进入该页面时,会发生以下情况:
- 浏览器将我带到 anchor ,但几分之一秒后我又回到顶部。我试过这个:
$(window.document).bind("mobileinit", function() {
$.mobile.ajaxEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.changePage.defaults.changeHash = false;
$.mobile.pushStateEnabled = false;
});
所以,这些都没有帮助。我还尝试在 pagecreate
事件上执行类似 window.location.href = window.location.hash
的操作。它不起作用。
有人能解开这个谜团吗?
最佳答案
你尝试过吗:
<div data-role="page">
<a rel="external" href="#comments">comment</a>
...
</div>
<div data-role="page" id="comments">
...
</div>
关于jquery - 如何使 jQuery Mobile anchor 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12529434/