简体   繁体   English

jquery window.load()函数不会在ios5上触发

[英]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. 我的页面上有一个简单的加载div,在整个页面加载后淡出。 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. 这个代码在我的所有桌面浏览器和我的手机Chrome中运行良好,但它不适用于我的ipod 3g的ios5 safari浏览器。加载器不会消失,因此网页没用。 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. ps:我不想在这里使用document.ready ,因为我正在尝试做的事情是在页面完全加载时发生的。

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 : 所以我自己认为使用javascript的本机load事件将解决问题:

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

cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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