zanhtet
zanhtet

Reputation: 2050

How to know the page that is came from brower history or not

I created a html page(page1). This page contain a link and a submit button. If the link is clicked, the another html page(page2) is reached. If the submit button is clicked, this page is post back to server and go to another html page(page2). If the user is clicked the back button of browser in page2, the page1 will be shown. So, the user can click submit button next time. I do not like this. So, I want to check page1 that is came from browser history or not. Can I get it.

Upvotes: 0

Views: 346

Answers (2)

Sujit Agarwal
Sujit Agarwal

Reputation: 12508

One way I could do is include the time the page was generated on the page and then use some Javascript to compare the local time while the page was generated. If time is different by a threshold, the site has been in a cache. The problem with this is if the client computer has a time set incorrectly, but you can avoid this by having the client include the current system in order to generate the page and send that value to the customer.

Upvotes: 0

Chris Eberle
Chris Eberle

Reputation: 48795

You can always check the referrer. I don't know what your server is using, so I can't tell you how to do this. However you should know that it is possible to fake a referrer, so this isn't exactly fool-proof.

Upvotes: 1

Related Questions