如何在URL中禁用#hashtag [英] How to disable #hashtag in URL

查看:194
本文介绍了如何在URL中禁用#hashtag的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

问题:

现在我从默认主页 page1 转到另一个 page2 ,因此网址为 localhost / index .PHP#2页。当我刷新页面时,它仍然在 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 的默认值,它在< head> 。

To disable updating URL with #hashtag, change default of changePage which handles pages transition before loading jQuery Mobile script in <head>.


演示:#Hashtag(已禁用 / 已启用

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆