window.history.back()显示&“文档已过期".页面,可以解决吗? [英] window.history.back() shows "Document Expired" page, any way around that?

查看:41
本文介绍了window.history.back()显示&“文档已过期".页面,可以解决吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户要求用户在单击结果后能够返回到包含搜索结果的页面.现在,这是一个简单的jQuery调用:

Client is asking for the ability for users to go back to a page full of search results after clicking on a result. Right now it's a simple jQuery call:

$('a.detail-back-button').on('click', function(evt) {
    evt.preventDefault();
    window.history.back();
});

但是,这显示了Firefox中的文档过期"页面.我知道它的存在是为了安全,但是客户无论如何都希望实现这一点.我已经进行了一些搜索,找到了解决该问题的php解决方案...

This shows a "Document Expired" page in Firefox, however. I know it's there for security, but the client wants this implemented anyways. I've done some searching around and I've found a php solution to the problem...

session_cache_limiter('private_no_expire')

...但这是基于Django的网站.还有其他解决方案吗?

...but this is a Django-based web site. Are there any other solutions?

UPDATE 02/21/13

以下解决方案有效,但仅适用于非IE浏览器.IE8/9/10似乎没有重新请求上一页.有IE解决方法吗?

The solution below works but only for browsers that aren't IE. IE8/9/10 doesn't seem to re-request the previous page. Is there an IE workaround?

推荐答案

这与 POST 请求的按定义的非幂等性质有关.IE. POST 是一种有效的动作,因此重复进行是不安全的.为了防止这种情况的发生,某些浏览器在重新提交原始表单之前会显示一个带有确认消息的占位符页面.

This has to do with the by definition non-idempotent nature of POSTed requests. I.e. a POST is an action which has an effect, and is thus unsafe to repeat. To prevent this from happening accidentally, some browsers show a placeholder page with a confirmation message before resubmitting the original form.

最可靠的解决方案(可能是唯一的一种)是改为使用 GET 方法提交表单,这还是很有意义的.

The most reliable solution -possibly the only one- is to submit your form using the GET method instead, which makes sense anyway.

这篇关于window.history.back()显示&“文档已过期".页面,可以解决吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆