简体   繁体   中英

jquery window.load() function won't trigger on ios5

I have a simple loading div on my page that fades out when the whole page has been loaded. I am using a simple code snippet as follows :

$(window).load(function(){
    $('#loading').fadeOut(500);
});

this code is working fine in all my desktop browsers and in my mobiles chrome, but it won't work with my ipod 3g's ios5 safari browser.The loader won't go away thus the webpage is useless. What can I do to solve this problem? ps: I don't want to use document.ready here because what I'm trying to do happens when the page has been COMPLETELY loaded.

You should do this:

$(function(){
    $('#loading').fadeOut(500);
});

So I figured it out by myself that using javascript's native load event will solve the problem :

window.addEventListner('load', function(){
    //do the stuff
});

cheers

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