我正在加载图片
obgImage.onload = function ( imageReady = true )
document.getElementById('vimeo').onload= function() {
videoReady = true;
}
当这两个准备就绪时,我应该用什么来识别?
if(videoReady == true && pageReady == true){
$('#loading').fadeOut();
}
如何让if语句不断检查?我有查询
答案 0 :(得分: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函数,则使用此函数将被调用两次