What are the best practices for working with the back button in IE (and Firefox)

I know this in the old problem, but I cannot figure out how to deal with the back button.

I am writing a web application with a lot of data movement between the browser and the server server. I am currently using a post and, of course, when the user bypasses the application’s navigation and uses the back button, both IE and Firefox pop-up messages asking the user if they want to resend the data.

I tried "get" and besides all the data displayed in the url, IE8 still generates a message.

In addition, I can’t determine when the message causes the message, and when not, because I have test cases sending data when the "Back" button does not cause the message.

My environment is JavaScript, PHP and MySQL.

Any help or pointer to the location of the study is appreciated.

Edited by:

I wrote 3 small pages to check the publication a-> b-> c-> a and they do not trigger postdata messages. I do not know why:

A

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test post A</title>
</head>
<body>  
<h1>testPostA.php</h1>
<h3>Came from <?php print (isset($_POST['data'])?$_POST['data']:"NoWhere"); ?></h3>
<form action="testPostB.php" method="post">
    <input name="data" type="text" value="from testPostA.php" />
    <input type="Submit" value="Submit To: testPostB.php" />
</form>
</body>
</html>

IN

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test post B</title>
</head>
<body>  
<h1>testPostB.php</h1>
<h3>Came from <?php print (isset($_POST['data'])?$_POST['data']:"No where"); ?></h3>
<form action="testPostC.php" method="post">
    <input name="data" type="text" value="from testPostB.php" />
    <input type="Submit" value="Submit To: testPostC.php" />
</form>
</body>
</html>

FROM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test post C</title>
</head>
<body>  
<h1>testPostC.php</h1>
<h3>Came from <?php print (isset($_POST['data'])?$_POST['data']:"No where"); ?></h3>
<form action="testPostA.php" method="post">
    <input name="data" type="text" value="from testPostC.php" />
    <input type="Submit" value="Submit To: testPostA.php" />
</form>
</body>
</html>
+3
source share
3 answers

The Post / Redirect / Get pattern will prevent repeated POST notification. However, you still need to make sure your application can handle / reject duplicate forms, etc.

1

, Javascript, , , "", ..

2

. , POST, . , , (.. ). , , -, Post/Redirect/Get, , .

, , , = "" , , .. GET , URL POST.

+5

ajax , , , , .

+3

, , , ​​ POST. - AJAX POST'ing, , .

To avoid receiving this prompt, you can simply use AJAX or POST and then redirect. However, this is the behavior of a large number of web applications (e.g. Amazon cart). I do not quite understand the context or behavior of your application, but I'm not quite sure that this is a problem that you need to worry about, especially if you do not allow duplicate data.

+2
source

Source: https://habr.com/ru/post/1723503/


All Articles