ztech
ztech

Reputation: 560

Fire JQuery/ Javascript after Back Button in Safari 9

When I navigate back using the browser back button in Chrome/ Firefox my website works just as expected (the same as it would if loaded without navigating backward).

In Safari after navigating back I can't get any 'on load' type event to fire whether the standard document ready or some hackaround found on here on StackOverflow. I'm not doing anything special, I just really need to call:

$( document ).ready(function() {
  // analyticsEvent();
  // startAnimation();
  // etc();
});

Has anyone encountered the same problem?

Upvotes: 3

Views: 2506

Answers (1)

Milan
Milan

Reputation: 859

Try this

$(window).bind("pageshow", function(event) {
    if (event.originalEvent.persisted) {
        window.location.reload() 
    }
});

Upvotes: 11

Related Questions