Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome tracks 2 history entries even when submitting a PRG-based form
    primarykey
    data
    text
    <p>Chrome tracks TWO history entries - instead of only ONE - when submitting a form that implements "Post + Same Page Redirect + Get" method.</p> <h2>The steps that demonstrate this strange behaviour.</h2> <p>1 - I browse to the form page Naked form page : demo.html. Naked form page: <img src="https://i.stack.imgur.com/wroxT.png" alt="Naked form page (demo.html)"></p> <p>2 - I fill the form. Filled form:</p> <p><img src="https://i.stack.imgur.com/oT33m.png" alt="Filled form (demo.html)"></p> <p>3 - I submit the form. Submited -thus empty - form (at demo.html, as redirected from my PRG-based redirect-to-same-page.php):</p> <p><img src="https://i.stack.imgur.com/SiOaP.png" alt="enter image description here"></p> <p>4 - I click on the browser's "back" button once.</p> <h3>Chrome jumps back to the filled form (step)</h3> <p><img src="https://i.stack.imgur.com/uYP82.png" alt="enter image description here"></p> <p>5 - I need to click on the browser's "back" button another time to reach the page I was browsing before I went to that form page (say my browser's "google" default page): <img src="https://i.stack.imgur.com/9IwLW.png" alt="enter image description here"></p> <p>This happens with Chrome (version 25.0.1364.172) and Safari (6.0.2)</p> <h2>What I'm expecting</h2> <p>I'm expecting to have a single browser's "back" click to reach the page before the form. This is actually how Firefox (19.0.2) Opera (12.11), and IE (from version 6 to latest 10) behave.</p> <h2>My source code</h2> <p>demo.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="redirect-to-same-page.php" method="post"&gt; Type something and submit: &lt;input type="text" name="something" /&gt; &lt;!-- optional: autocomplete="off" --&gt; &lt;input type="submit" value="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>redirect-to-same-page.php</p> <pre><code>&lt;?php header('Location: demo.html', true, 302); // not any of true/false 302/303 combinations are working // not working either: header("Refresh: 0; demo.html"); exit; ?&gt; </code></pre> <h2>What Chrome's web inspector reveals...</h2> <p>1 Before submission : <img src="https://i.stack.imgur.com/6NIYI.png" alt="enter image description here"></p> <p>2 After submission : <img src="https://i.stack.imgur.com/umD7W.png" alt="enter image description here"></p> <h2>My questions</h2> <p>I read similar questions and potential answers but none of them solved my problem.</p> <p>Is this behaviour a Chrome/Safari issue or a feature* ? (* in the case submission fails it retains a full backup of your filled form)</p> <p>Is there a correct or more defensive code for node.js or php to avoid this behaviour ?</p> <p>Thanks for your help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload