0

我使用 jquery mobile 1.1.1 创建了一个网络应用程序

作为我的应用程序的一部分,我构建了密码检索功能。如果用户需要重置密码,他们会填写一份表格并收到一封电子邮件,其中包含一个链接,其中包含密码重置页面的地址和其他两个参数:

www.mywebapp.com/demo.html#resetPassword?x=123&y=123

最初的问题: 当用户点击链接时,即使地址栏中的 URL 显示:www.mywebapp.com/demo.html#resetPassword?x=123&y=123 我明白,他们也会看到 Web 应用程序的主页jQuery mobile 不支持在哈希后传递参数,所以我想出了以下解决方案。

一个小不便的解决方案: 我将以下代码放在一起,它读取 URL,捕获我的两个参数并将用户重定向到密码重置页面:

$( document ).bind( "pagebeforeshow", function() {
    //cpe("parameter") will check whether the specified URL parameter exists
    if(cpe("x") && cpe("y")){
        //gpv("parameter") captures the value of the specified URL parameter
        recovery.username=gpv("x");
        recovery.token=gpv("y");
        $.mobile.changePage("#resetPassword");
    }
})

不便之处,以及我当前的问题: 当用户点击电子邮件中的链接时,浏览器会启动并打开应用程序的主页,然后它会快速显示#resetPassword 页面。我了解发生这种情况是因为我正在更改页面

$.mobile.changePage("#resetPassword");

但是,如何修改上面的代码,让用户根本看不到主页,直接进入#resetPassword 页面?

4

2 回答 2

0

我遵循了 Raymond Camden 的建议,并在我的 html 中添加了以下内容:

<pre>

<!--Start of blank initial page: #initPage-->
<div data-role="page" id="initPage">
    <div data-role="content"></div>
</div>
<!-- /page -->

</pre>

我还在我的javascript中添加了以下内容:

//init page -> path control hub
$( document ).bind( "pagebeforeshow", function() {
    var pageid=$.mobile.activePage.attr('id');
    if(pageid=="initPage"){
        if(cpe("x") && cpe("y")){
            recovery.username=gpv("x");
    recovery.token=gpv("y");
    $.mobile.changePage("#resetPassword");
    }else{
                $.mobile.changePage("#info");
                }
    }
})

它现在正在工作。

于 2012-09-17T14:35:40.533 回答
0

使用没有内容的空白初始页面。默认情况下,对您的初始页面执行 changePage 但在其他情况下,例如 resetPassword 情况,您将 changePage 改为该页面。

于 2012-09-16T18:59:34.793 回答