0

On iPhone (at least ios8), if we animate stuff as the user is leaving the page (for example he clicked a link), when the user press the "back button", he come to the page and the previous state or the webpage with the style property changed by animation stay there.

It looks like Safari doesn't reload the page, but cache the DOM state and just rerender it or something.

Anyone know workaround this behavior? Or have links to relevant documentation describing the behavior?

Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134

2 Answers2

0

You can try a crude js 1 second setinterval? set a datetime variable, and next interval check if the existing variable is 1 second ago.

if not means the user has navigated to other page.

dtjokro
  • 122
  • 7
0

The behavior is related to Safari's Back/Forward cache. You can learn about it on the relevant Apple documentation: http://web.archive.org/web/20070612072521/http://developer.apple.com/internet/safari/faq.html#anchor5

Apple's own fix suggestion is to add an empty iframe on your page:

<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
    this frame prevents back forward cache
</iframe>

This question also have been answered here: Prevent safari loading from cache when back button is clicked (he solution proposed there diverge from the Apple documentation)

Community
  • 1
  • 1
Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134