Wednesday 9 December 2009

How Different Web Browsers Handle history.go Function

I am using php and html to do the case.

Step 1:
Create a search page using form which the action of the form will be the search page itself, e.g. pageA.html.


Step 2:
In pageA.html, create a link to a new page, e.g. pageB.html that will be shown after submission of form.


Step 3:
In pageB.html, create a button that use history.go(-1) to move backward to the previous page.


Step 4:
Now let's try it.
a. Go to pageA.html
b. Click on the "submit" button.
c. You should be brought to pageA.html with a link to pageB.html now.
d. Click on the link.
e. You should be brought to pageB.html
f. Now click on the "back" button
g. You should have the following the following result

Opera 10.10: pageA.html after form submission is still there
Google Chrome 4.0.249.30: error page with title "Confirm Form Resubmission"
IE 7.0.6000.16890: error page with title "Webpage has expired"
Safari 4.0.4(531.21.10 ): a confirmation prompt to ask you to resend the form
Mozilla Firefox 3.5.5: a confirmation prompt to ask you to resend the form

Step 5:
However, if you access pageA.html by parsing variables using URL and not by submitting the form, and then click on the link to pageB.html and click "back" button in pageB.html, you will see that you will be at the pageA.html where it has the variables parsed using URL already.
E.g. in pageA.html


So you will need to consider the structure of the website before using history.go(-1).