0

我正在加载图像

obgImage.onload = function ( imageReady = true )
document.getElementById('vimeo').onload= function() {   
                        videoReady = true;
}

当这两个都准备好时,我应该用什么来识别?

if(videoReady == true && pageReady == true){
        $('#loading').fadeOut();
    }

我如何使 if 语句不断检查?我有疑问

4

1 回答 1

1
var videoReady = false,
    imageReady = false,
    _ready = function() {
        if (videoReady && imageReady) {
            // do your code
        }
        else {
            // waiting for the other onload function to be called
        }
    };

obgImage.onload = function () {
    imageReady = true;
    _ready();
};

document.getElementById('vimeo').onload= function() {   
    videoReady = true;
    _ready();
};

如果两个元素都将触发其 onload 函数,则使用此准备函数将被调用两次

于 2013-10-04T14:17:14.510 回答