从(window.location.hash)中删除哈希

Remove hash from (window.location.hash)

本文关键字:删除 哈希 hash window location      更新时间:2024-03-31

我使用的是这个代码

$("#reset_filter").on("click", function(e) {
    window.location.hash = "";
    window.location.reload();
});

用于重置页面上的URL,但由于URL末尾的(window.location.hash),我总是得到#。是否可以以某种方式从URL中删除hash?我已经试过了

window.location.href.substr(0, window.location.href.indexOf('#'))

window.location.href.split('#')[0]

但它不起作用,请提出任何建议并提供帮助。

否。如果您明确地告诉javascript设置一个哈希位置,那么该位置中将有一个哈希。

您可以重新加载页面或使用

从url 中删除哈希

这个:

<a href='#anchor'onclick='返回anchor跳转(this.href)'>单击

http://ajaxian.com/archives/ajax-tackle-the-refresh-button

但不管怎样,你用的是什么浏览器?