jquery-mobile - 如何删除 jQuery Mobile RC2 中 URL 中的历史记录?

标签 jquery-mobile transition

我正在使用 jQuery Mobile RC2。我需要在不跟踪历史记录的情况下将页面从一个页面更改到另一个页面。

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

例如:

Actual : /DefaultSP.aspx#searchPage

Expected : /DefaultSP.aspx(need to remove #searchPage in URL)

提前致谢。

最佳答案

我不确定他们是否更改了关于如何使用它的标记,但这里是文档:

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>

关于jquery-mobile - 如何删除 jQuery Mobile RC2 中 URL 中的历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8008071/

相关文章:

javascript - 将复选框添加到 jQuery Mobile 中的可折叠列表标题

swift - 以编程方式执行 segue

javascript - Div 过渡到 div onclick

JQuery Mobile 百分比高度问题

javascript - JQuery Mobile 滑动 .load .prev 和 .next

javascript css3 每 2 秒更改一次背景颜色

html - 将内容切换链接样式化为单选按钮

css - 存在外部链接时,SVG css3 过渡填充不起作用

html - Jquery Mobile 内容未填充 100%

jquery - 如何获取 jQuery Mobile 创建的子页面上的页眉和页脚