在使用window.location.hash=''
页面从网址中删除哈希值后,重新加载到Firefox中。从URL中删除哈希值
编辑
例子:
wwww.Mysite.come/#page=1
在按钮我使用删除哈希值的点击下面的代码
window.location.hash=''
取出后散页在Firefox中重新加载。
我不想重新加载页面我只是想从URL
删除哈希如何解决呢?
在使用window.location.hash=''
页面从网址中删除哈希值后,重新加载到Firefox中。从URL中删除哈希值
编辑
例子:
wwww.Mysite.come/#page=1
在按钮我使用删除哈希值的点击下面的代码
window.location.hash=''
取出后散页在Firefox中重新加载。
我不想重新加载页面我只是想从URL
删除哈希如何解决呢?
从https://developer.mozilla.org/en/DOM/window.location:
实例
每当位置对象的属性被修改时,一个文档 将使用URL被加载仿佛window.location.assign()已经 称为修改后的网址。
这个问题我想地址你想使用什么jQuery的:
Change hash without reload in jQuery
其他相关问题:
Change the URL in the browser without loading the new page using JavaScript
How to remove the hash from window.location with JavaScript without page refresh?
How can I change Firefox window.location.hash without creating a page reload?
以防其他人仍在寻找解决方案。当页面加载时试试这个。
history.pushState("", document.title, window.location.pathname);
如果我理解正确的话,
<a href="#someElementID" id="myLinkName">Some Text</a>
点击浏览器中上面的链接通常会导致在地址栏中添加的哈希值,像www.websitename.com#someElementID < - 这是你想要的阻止,是吗?
我只是测试它是否工作,不刷新页面的解决方案是:
event.preventDefault();
这个工程“点击()”事件,涉及链接到元素的ID的锚标记,如在上面的锚点标记示例中。在行动上,它看起来像这样在你的“点击()”事件:
<script>
$('#myLinkName').click(function(){
event.preventDefault();
//the rest of the function is the same.
});
</script>
现在,点击同一链路上留下了与同一URL www.websitename.com地址栏,没有从加入哈希点击锚点。
我们可以通过在点击函数中返回false来移除/逃避追加哈希。
<script>
$('#add_user').click(function(){
//your custom function code here..
return false;
});
</script>
<a id="add_user" href="#">Add Card</a>
我很抱歉,但您的问题没有意义。你能否澄清并展示一些代码示例? – webnoob 2012-04-05 09:40:15
你为什么要删除哈希? – 2012-04-05 09:42:15
我提交了一个Ajax表单,部分页面正在变化..在这一步之后,哈希值没有意义,这就是为什么我想删除它 – suma 2012-04-05 09:46:54