$('img').load(function(){ ... });
- 是不是可以信任的東西(在你的插件我看到這個代碼)。在這裏,你可以看到爲什麼: http://api.jquery.com/load-event/(開始從caveats
字讀)
下面是小例子來形容麻煩:
$(document).ready(function(){
$('img').load(function(){
// this event going to fire only if document was ready after image was loaded; (very seldom, almost never)
console.log('Fired?! You are lucky today!');
});
$(document.body).append('<img src="http://stat19.privet.ru/lr/0b164d8151948d2fdedfbfdc420f5392?temp=2" id="some"/>');
$('#some').load(function(){
// this event will fire often, except of cases descripted in `load` event manual
console.log('Huugh. Today have fired. But I don\'t know about tomorrow');
});
var temp = new Image;
temp.src = 'http://photo.a42.ru/photos/92772/medium/11757.jpg';
temp.onload = function(){
// this event going to fire almost always except of cache issue with IE, that can be handled by skipping cache with `?nothing=random` appending to image URL
console.log('Okay, okay! I\'ve fired');
}
$(document.body).append(temp);
});
你可以在這裏運行:http://jsfiddle.net/p6Cpy/
認爲它有什麼與您的jQuery圖像加載器,名稱krioImageLoader – Pitchinnate 2013-04-26 19:12:03
感謝您的答覆!我試圖刪除它,但不幸的是頁面沒有任何影響。圖像仍然不加載... – drasticdub 2013-04-26 19:23:50
你是否得到了小負載微調或破碎的圖像? – Pitchinnate 2013-04-26 19:38:26