2012-03-19 56 views
0

想知道:如何從Jquery Mobile中的URL中刪除hashtag?

我需要更新URL並在過渡到新的Jquery移動頁面之前/之後刪除所有hashtag參數。

現在,我想這樣的,但它不工作:

$(document).on('pagebeforeshow', 'div:jqmData(role="page")', function(event, data){  

    var documentUrl = $.mobile.path.parseUrl(location.href); 
    // update path and history 
    $.mobile.path.set(documentUrl.hrefNoHash); 

}); 

這是可能的呢?如果是這樣,我該如何正確地做到這一點?

感謝您的幫助!

+0

http://stackoverflow.com/questions/9683862/in-mjq-how-can-i-remove-hash-from-the-url – dali 2012-03-19 22:02:23

回答

0

當您嘗試更改頁面時,您可以關閉散列。希望這段代碼有幫助。

例子:

$.mobile.changePage("#About", {transition: "slide",reverse: true,changeHash: false}); 
+0

好主意。我也試過這個。它的工作,所以你點頭。然而,在我的設置中,我正在「結束」window.history和hashtag,並且不應該過渡到window.history。所以在弄清楚如何管理hashtag後,我仍然堅持使用我的window.history條目。我最終通過計算轉換和頁面隱藏結束了window.history的展開,我正在做一個展開ala window.history.go(-myCounter)。這也重置了標籤,所以我是一個快樂的露營者! – frequent 2012-03-21 07:18:37

+0

,它不會觸發任何Jquery Mobile轉換 - 如果您解開正確的金額:-) – frequent 2012-03-21 07:19:19

相關問題