gpt4 book ai didi

javascript - 防止 Jquery Mobile 处理 URL 哈希?

转载 作者:行者123 更新时间:2023-11-30 08:43:19 25 4
gpt4 key购买 nike

我在现有的 Web 应用程序中使用 Jquery Mobile。问题是,Jquery Mobile 正在处理所有 URL 哈希。例如:

mysite.com/#foo

在这里,散列“foo”被发送到 Jquery Mobile,它正在处理它,而不是让我的非 jquery Mobile 代码处理它。

是否可以防止 Jquery Mobile 干扰 url 哈希?

最佳答案

jQuery Mobile 的默认行为是监听 hashchange事件和更新 URL 哈希 以处理页面的历史,仅当启用Ajax 时。

要处理页面链接,changeHashhashListeningEnabled 属性应在首次运行时禁用 mobileinit .此事件在加载 jQuery Mobile 库和 .ready() 之前触发;它应该用来改变Global Settings框架。

<script src="jquery.js"></script>
<script>
$(document).on("mobileinit", function () {
$.extend( $.mobile, {
changePage.defaults.changeHash: false,
hashListeningEnabled: false
});
});
</script>
<script src="jquery.mobile.js"></script>

关于javascript - 防止 Jquery Mobile 处理 URL 哈希?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24272818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com