最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Fire JQuery Javascript after Back Button in Safari 9 - Stack Overflow

programmeradmin8浏览0评论

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?

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?

Share Improve this question asked Apr 20, 2016 at 17:10 ztechztech 5606 silver badges13 bronze badges 1
  • i Think that's happen because safari uses cached javascript, maybe use pageshow method insted of .ready will work – Nico Commented Apr 20, 2016 at 17:17
Add a ment  | 

1 Answer 1

Reset to default 11

Try this

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

评论列表(0)

  1. 暂无评论