如何获得“确认表格重新提交"?当用户尝试刷新浏览器时 [英] How to get "Confirm form resubmission" when user trying to refresh browser

查看:194
本文介绍了如何获得“确认表格重新提交"?当用户尝试刷新浏览器时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,不允许用户通过单击浏览器刷新按钮或按F5刷新页面.因此,我想模拟表单重新提交"以显示提示消息.

I have a page that doesn't allow user to refresh the page by clicking browser refresh button or pressing F5. So I want to simulate 'form resubmission' in order to show prompt message.

有人可以指导我实施该方法吗?

can someone guide me an approach to implement it?

是否可以使用跨浏览器解决方案?

Is there any cross-browser solution available for that?

推荐答案

要刷新而未收到提示,必须使用HTTP GET

To refresh without getting the prompt the page must have been fetched using HTTP GET

使表单具有method="GET"而不是method="POST"(并修复服务器进程以适当地使用此更改)

Make the form have method="GET" instead of method="POST" (and fix server processes to work with this change as apropriate)

或者,在会话中缓存帖子数据,并在提交表单后立即使用HTTP代码303重定向到显示页面.

Alternatively cache the post data in a session and redirect to the display page using HTTP code 303 immediately after form submission.

如果要引起提示,请在POST表单上将将用户引导至页面的链接创建为提交"按钮.如果用户收到GET请求,则向他们提供一个页面,该页面具有javascript,该页面提交了将请求转换为POST请求的表单.

If you want to cause the prompt, make the link that takes the user to the page into a submit button on a POST form. if a user arrives with a GET request have serve them a page having javascript that submits a form converting the request into a POST request.

这篇关于如何获得“确认表格重新提交"?当用户尝试刷新浏览器时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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