在表单提交后点击“返回”按钮时,防止浏览器激活 [英] Prevent browser waring when you hit the 'go back' button after form submit

查看:324
本文介绍了在表单提交后点击“返回”按钮时,防止浏览器激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个小问题。其实,更多的烦恼。



我在我的索引页上有一个表单,它有一个小的搜索表单:



< form action =search.phpmethod =post>

< input name =searchtype =text/> >
< input type =submitname =submit>



现在位于search.php文件中I只需使用$ _POST ['search']来检索我正在搜索的值。该文件还显示实际的搜索结果,我可以点击该结果进入该页面。搜索实际上是在数据库上完成的。此外,因为我的搜索从DB返回前10个随机结果,所以如果我点击'后退'按钮并确认警告,搜索将再次执行,并返回一组不同的结果。



如您所知,问题在于当您点击其中一个搜索结果,然后在浏览器中点击返回时,您会看到该浏览器警告要显示此页面,Firefox必须发送信息以重复以前执行的任何操作(如搜索或订单确认)。'



防止这种情况发生的最简单方法是什么?我研究了PRG技术,但我不确定如何实现它。



任何帮助都很棒。
谢谢。
Bruno。

解决方案

可以在这里使用GET方法, GET方法。


I have a little problem here. Actually, more of an annoyance.

I have a form on my index page that has a small search form:

<form action="search.php" method="post">
<input name="search" type="text" />
<input type="submit" name="submit">

now on the search.php file I just use the $_POST['search'] to retrieve the value that I'm searching. This file also displays the actual search results, which I can click on to go to that page.The search is actual done on the database. Also, because my search returns the top 10 random results from the DB, if I hit the 'back' button and confirm the warning, the search will be executed again, and will return a different set of results.

The problem, as you know, is that when you click on one of the search results and then hit 'back' on the browser, you get that browser warning about 'To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.'.

What's the easiest way to prevent this from happening? I looked into that PRG technique but I'm not sure how to implement that.

Any help would be great. Thanks. Bruno.

解决方案

Is it OK to use GET method here, users won't see warning if form sent by GET method.

这篇关于在表单提交后点击“返回”按钮时,防止浏览器激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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