简体   繁体   中英

$(window).load(function() event not firing on Safari Mobile

I need to run some JQuery code after the page completes loading but although it's working on desktop browsers it's not firing the event on Safari Mobile.

This is the code:

$(window).load(function() {
   //Alert('event was fired');
});

I'm also using JQuery Mobile ... don't know if it has something to do with the problem.

This script will only fire on the initial page load, as all subsequent page transitions are AJAX based and will not fire a document ready or window load event.

The closest match, given your requirements is the pagechange event, provided by JQM. This fires after page has been loaded into the DOM and the transition animation has completed.

$(document).live('pagechange',function(){
  //your logic
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM