MacOS – Safari 6 refreshes when I go back

macossafari

I have this annoying problem with Safari 6, each time I go back or forward (both the toolbar buttons or two singer swipe) the tab refreshes. Here is a quick video to illustrate the problem: https://dl.dropbox.com/u/3257155/safari-refresh.mov

Normally I wouldn't really mind, it kinda grown on me over time (I'm not really sure this started when I updated to Safari 6 or to Mountain Lion – there was about a week between the updates), but my client found a bug in the web app I build (some buttons stop responding when he goes back – he is still on Lion) and I can't reproduce the problem because my Safari refreshed every time.

So my question is, what is the normal behavior for Safari? And how/if can I make Safari not refresh?

UPDATE

Turns out the problem was that Safari doesn't (by default) fire the onLoad even when on the "back action". I couldn't reproduce the bug on my machine because apparently the 1password extension causes the onLoad event even when you go back.

Best Answer

Turns out the problem was that Safari doesn't (by default) fire the onLoad even when the "back action" is performed (using the back button or the two finger swipe) but I couldn't reproduce the bug on my machine because apparently the 1password extension causes the onLoad event even when you go back.


Further explications at Render's request:

So let's assume this code on all pages:

$(document).ready(function () {
    alert('test');
}

And this sequence of actions:

  1. open page-1.html
  2. open page-2.html
  3. Go back
  4. Go forward

Safari won't show the alert after step 3 and 4, so I the onLoad event is not fired and the page .js continues the execution from where it left off when you navigated away from the page.

Also in the current version 6.0.3, having 1password extension (3.9.14) seems to have no effect over this behavior.

Hope that helps. This shouldn't matter in most cases, it's only when you write bad code (like it did) it will bit you in the arse :)