在safari和opera中,.load的回调函数不会等待未完成的图像被完全加载。使用缓存的图像,它可以很好地工作。
代码有点复杂,我会尝试简化...
所以,我的js是这样的:
$('#chatwindow_' + thread_id).load('/chat.php?thread_id=' + thread_id, function(){
$('#chatwindow_' + thread_id).children('.chat_messagebox').load('/messages.php?sel=chat&latest_messages=10&thread_id=' + thread_id, function(){
//THIS IS BEING EXECUTED BEFORE THE IMAGES ARE FULLY LOADED,
//BUT I EXPECT IT TO BE EXEC AFTER THE IMAGES ARE LOADED
$(this).scrollTo('max',0);
$('#chatwindow_' + thread_id).find('.messages_newcontent').focus();
});
});
messages.php SEL =聊天:
<? include(gen_path("/messages_messagelist.php")); ?>
messages_messagelist.php:
while($x < $x_total){
load_attachments("message_".$message_row['id'], $max_width_of_att_field)
}
最后是函数的重要片段:
return "<img src='/upload/attachments/".$attachments_row['id']."' width='160' class='download_file info_nextsibling' id='downloadfillabeobj_".$attachments_row['id']."'>"
就是这样 - 如果这个最终&lt; img&gt;没有缓存,它在调用初始.load回调函数后完全加载 - 关于如何等待所有未缓存图像的任何想法?