如何在 URL 中禁用 #hashtag [英] How to disable #hashtag in URL
问题描述
我的 JQM 包括三个 data-role="page"
.
My JQM includes three data-role="page"
.
问题:
现在我从默认主页 page1 转到另一个 page2,因此 URL 是 localhost/index.php#page2
.当我刷新页面时,它仍然在page2.
Now I go to another page2 from the default home page1, so the URL is localhost/index.php#page2
. When I refresh the page, it is still in page2.
这是一种可以返回到 localhost/index.php
而不是当前页面(不带任何参数)的方式吗?
Is that a way that it can go back to localhost/index.php
instead of current page (without any parameters)?
推荐答案
要禁止使用 #hashtag
更新 URL,请更改 changePage
的默认值,它在加载 jQuery 之前处理页面转换.
To disable updating URL with #hashtag
, change default of changePage
which handles pages transition before loading jQuery Mobile script in <head>
.
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>
这篇关于如何在 URL 中禁用 #hashtag的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!