window.history.back() shows “Document Expired” page, any way around that?

冷暖自知 提交于 2019-12-01 07:07:56

问题


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();
});

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')

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

UPDATE 02/21/13

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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/14965718/window-history-back-shows-document-expired-page-any-way-around-that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!