【问题标题】:How to remove the # (hash) from the URL in intra page linking?如何从页面内链接中的 URL 中删除 #(哈希)?
【发布时间】:2012-01-13 18:41:00
【问题描述】:

在jquery mobile中我正在使用

$('#somebutton').click(function () {
    $.mobile.changePage("#searchResult", "slide");
});

切换到另一个页面。这个#searchResult 被添加到 URL 中我不希望发生这种情况....那么我该如何从 URL 中删除它。

提前致谢。

【问题讨论】:

  • 如果添加“location.hash = '';”会发生什么?
  • 您在页面加载时尝试过location.hash = ""; 吗?
  • @Joseph :如果我指定 location.hash = "";像这样然后页面返回到父页面我想留在searchResult页面本身。
  • 我自己找到了解决方案 $.mobile.changePage("#details", { transition: "slide", reverse: false, changeHash: false });我们只需要将 changeHash 和 reverse 参数设置为 false。无论如何感谢@Aaron Joseph 的回答。

标签: jquery url hyperlink jquery-mobile


【解决方案1】:

试试这个:

$('#somebutton').click(function () {
    $.mobile.changePage("#searchResult", {changeHash:false});
});

来自JQM documentation

【讨论】:

  • 除了 $('a').... 之外,还有什么方法可以为每次点击链接执行此操作?你知道,一个可配置的 jquerymobile 选项还是什么?我找不到任何东西,但您的解决方案确实有效。
猜你喜欢
  • 1970-01-01
  • 2011-05-29
  • 2012-04-19
  • 2016-12-13
  • 1970-01-01
  • 2013-05-15
  • 2013-03-02
  • 1970-01-01
相关资源
最近更新 更多