即使用户注销后,单击“返回”也会向用户显示上一页。

发布于 2024-12-10 18:31:54 字数 283 浏览 0 评论 0原文

我的移动网站上有几个页面。一个页面允许用户登录,另一页面向用户显示他们的日期并允许用户注销。但是,当用户注销并重定向到登录页面时,他们可以单击后退按钮并返回到他们应该进行身份验证的页面。

我只是将一个 html 页面分为多个 div(“页面”),并使用 $.mobile.changePage 从一个页面导航到另一个页面。

我怎样才能做到当用户点击后退按钮时他们看不到他们的数据?

当我浏览回来时,我的“pageinit”没有被执行。如果是的话我可以检查用户是否登录......

I have couple of pages on my mobile web site. One page lets user log in and the other show user their date and lets user log out. However, when user is logged out and redirected to the login page they can click on back button and get back to the page where they supposedly authenticated.

I just have one html page divided into multiple divs ("pages") and using $.mobile.changePage to navigate from one page to another.

How can I make it so that when user does click on back button they don't see their data?

When I browse back my 'pageinit' doesn't get executed. If it was I would be able to check if the user is logged in...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半﹌身腐败 2024-12-17 18:31:54

示例:

JS

var $secure_token = true;

$('div').live('pageshow',function(event, ui) {
    // Check for secure token here
    if($secure_token != true) {
        $.mobile.changePage("#login", { transition: "slideup"} );
    }
});

// Act if user has logged out
$('#secure2').live('pageshow',function(event, ui) {
    $secure_token = false;
});

HTML

<div data-role="page" id="login">
    <div data-role="content">
        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
            <li data-role="list-divider">Redirect</li>
            <li><a href="#secure1">Secure Page 1</a></li>
            <li><a href="#secure2">Secure Page 2</a></li>
        </ul>
    </div>
</div>

<div data-role="page" id="secure1">
    <div data-role="content">
        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
            <li data-role="list-divider">Secure Page 1</li>
            <li><a href="#secure2">Secure Page 2</a></li>
        </ul>
    </div>
</div>

<div data-role="page" id="secure2">
    <div data-role="content">
        <p>Please hit the browser back button or right click and back</p>
    </div>
</div>

Example:

JS

var $secure_token = true;

$('div').live('pageshow',function(event, ui) {
    // Check for secure token here
    if($secure_token != true) {
        $.mobile.changePage("#login", { transition: "slideup"} );
    }
});

// Act if user has logged out
$('#secure2').live('pageshow',function(event, ui) {
    $secure_token = false;
});

HTML

<div data-role="page" id="login">
    <div data-role="content">
        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
            <li data-role="list-divider">Redirect</li>
            <li><a href="#secure1">Secure Page 1</a></li>
            <li><a href="#secure2">Secure Page 2</a></li>
        </ul>
    </div>
</div>

<div data-role="page" id="secure1">
    <div data-role="content">
        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
            <li data-role="list-divider">Secure Page 1</li>
            <li><a href="#secure2">Secure Page 2</a></li>
        </ul>
    </div>
</div>

<div data-role="page" id="secure2">
    <div data-role="content">
        <p>Please hit the browser back button or right click and back</p>
    </div>
</div>
软糯酥胸 2024-12-17 18:31:54

我认为这是正常行为,因为任何浏览器都会保存它呈现的上一个网页。我刚刚用我自己的网页进行了测试,它确实显示了信息,但是每当您尝试更改某些内容时,系统都会重定向到登录视图。

我的意思是,他们会看到以前的数据,但这些数据会过时,并且如果不先登录,他们将无法更改它。

I think it's normal behaviour, as any browser saves the previous webpage it rendered. I just tested with my own webpage, and it indeed shows the info, but whenever you try and change something, the system redirects to the login view.

I mean, they will see the previous data, but it will be stale, and they won't be able to change it without login in first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文