2011-11-04 68 views
3

我正在使用jQuery mobile RC2。我需要將頁面從一個頁面更改爲另一個頁面,而無需在歷史記錄中進行跟蹤。如何刪除jQuery Mobile RC2中的URL歷史記錄?

我使用$.mobile.changePage("#searchPage", "pop", false, false);

例如:

實際:/DefaultSP.aspx#searchPage

預期:/DefaultSP.aspx(need到 刪除#searchPage在URL)

在此先感謝。

回答

5

我不知道,如果他們改變了關於如何使用這個標記,但這裏的文檔:

JS

//transition to the "confirm" page with a "pop" transition without tracking it in history   
$.mobile.changePage("../alerts/confirm.html", { 
    transition: "pop", 
    reverse: false, 
    changeHash: false 
}); 

例子:

JS

$('#customNav').click(function() { 
    //transition to the "confirm" page with a "pop" transition without tracking it in history    
    $.mobile.changePage("#page2", { 
     transition: "pop", 
     reverse: false, 
     changeHash: false 
    }); 
}); 

HTML

<div data-role="page" id="home"> 
    <div data-role="content"> 

     <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f"> 
      <li data-role="list-divider">Home Page</li> 
      <li><a id="customNav">Page 2 (Click here)</a></li> 
     </ul> 

    </div> 
</div> 

<div data-role="page" id="page2"> 
    <div data-role="content"> 

     <ul data-role="listview" data-inset="true" data-theme="b" data-dividertheme="e"> 
      <li data-role="list-divider">Page 2 will not be history</li> 
      <li><a href="#home">Home Page</a></li> 
      <li><a href="#page3">Page 3 (Click here)</a></li> 
     </ul> 

    </div> 
</div> 

<div data-role="page" id="page3" data-add-back-btn="true"> 
    <div data-role="header" data-rel="back"> 
     <h1>clicking the back button should go to home page</h1> 
    </div> 
    <div data-role="content"> 

     <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f"> 
      <li data-role="list-divider">Page 3 (Click the back button in the header)</li> 
      <li><a href="#home">Home Page</a></li> 
     </ul> 

    </div> 
</div> 
+0

男人,你救了我!非常感謝。 – Stan

0

那麼,什麼是錯的做

document.location.href = document.location.pathname; 
+1

這增加了其OP想避免歷史狀態。另外,不會完全繞過jQuery Mobile框架嗎? – Walf

相關問題