问题
I am having a problem with my website. I have some animations when a redirect is happening to get a transition effect from page to page. The problem is that if a user clicks the Browsers Back button it goes to the previous page but it does not reset the animations so everything stays hidden as when you exited the page.
To have a demo of the error go to http://www.econtentsys.gr/affiliate/xenosk/temp/amigdalos/main.php , Click on About Me and then click on your browsers (history) Back button.
Is there anyway to reset the pages cache lets say every time the page gets showed so the transitions will always work ?
Only Google Chrome functions properly on me. All the other browsers are having the same error.
Thanks in advance.
回答1:
Your animation doesn't reset when you click the back button because the page is cached in the bfcache (Back-Forward Cache).
The linked article mentions several situations where bfcache is not used, one being when the unload
handler is uses. Therefore, the simplest approach would be to simple add an empty onunload
attribute to your <body>
tag, i.e.
<body onunload="">
p.s. I've only tested this in Firefox.
来源:https://stackoverflow.com/questions/8166208/jquery-history-back-button-to-reset