As zaccaria told you - this is really, really hard problem.
All because it clients (browser) specific case (mood) how it will process clicking on the Back button. I.e. if it will reload page from server / cache, if it will refill previously filled forms (some browser has such behaviour) etc. You haven’t even got sure if a JS / jQuery code included in such page will be re-executed (some browsers does not do this, when re-reading page from cache).
For example (a bit off-topic, but explaining the problem), if you use simple JS code:
for the link onClick event and click that link a few times, you will have a total mess in Firefox browsing history, as this browser is adding new position to history each time page is being reloaded (which IMHO is an absurd - this is still the same page and FF knows this, as it is responding for reload request; IE does not have such behaviour, if I’m not mistaken).
So, this example illustrates that there are many problems across browsers and this is one of biggest pains of web developers ever.
All I can recommend you here is to include your own back button, inside page content, and strongly advice your users (with clear, visible message) not to use browsers build-in back button - I seen such approach on some bank webpage and must admit that it is some kind of nice solution for this problem.