在使用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