简体   繁体   中英

Why $(window).load() doesn't work in IE10

I have the following script:

function AnimateRotate(d){
    var elem = $("#imgLogoWM");
    //elem.fadeIn(2000);
    $(elem).hide();
    $(elem).each(function(i) {
        if (this.complete) {
            $(this).fadeIn(1500);
        } else {
            $(this).load(function() {
                $(this).fadeIn(2000);
            });
        }
    });

    /*$({deg: -60}).animate({deg: d}, {
        duration: 2000,
        step: function(now){
            elem.css({
                 transform: "rotate(" + now + "deg)"
            });
            elem.fadeIn(2000);
        }
    });*/
}

$(window).load(function (){
    timer = setTimeout('auto_reload()', 1800000);
    AnimateRotate(0);
});

var timer = null;
function auto_reload() {
    window.location = 'index.htm';
}

It works great in IE < 10 and FF and Chrome and Avant and Opera. The AnimateRotate(0); does not work in IE10. Any idea how to go around it so it works in IE10 as well?

To sum up: use document-ready rather than onload: api.jquery.com/ready

$(document).ready( ...function stuff ...)  or with less code
$( function(){ ...function stuff ...});

maybe you like to hand over the variable name "auto_reload"

setTimeout(auto_reload, 1800000)

to be executed later on instead of the immediately executed function "auto_reload()" to the timeout method. Checkout, if IE does take care of this.

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