gpt4 book ai didi

javascript - 如何禁用 URL 中的#hashtag

转载 作者:行者123 更新时间:2023-11-30 08:51:57 26 4
gpt4 key购买 nike

我的 JQM 包括三个 data-role="page"

问题:

现在我从默认主页 page1 转到另一个 page2,所以 URL 是 localhost/index.php#page2。当我刷新页面时,它仍然在 page2

是否可以通过这种方式返回到 localhost/index.php 而不是当前页面(不带任何参数)?

最佳答案

使用 #hashtag 禁用更新 URL , 更改 changePage 的默认值在 <head> 中加载 jQuery Mobile 脚本之前处理页面转换.

Demo: #Hashtag (Disabled / Enabled)

<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).on("mobileinit", function(){
$.mobile.changePage.defaults.changeHash = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>

关于javascript - 如何禁用 URL 中的#hashtag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17111258/

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