图片延迟加载 做了一个生出图片后加载的jquery的事件,但是生成图片慢一些,导致图片显示不错来,需要刷新页面,怎么才能解决这根问题呢?我实在thinksns里应用的,用过一个js叫但是不起作用。求高手帮忙解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用onload。onload="js()";图片加载完再执行js。 需要先执行jquery生成图片,然后才能加载,图片路径是确定的。虽然是生成图片的程序先进行但是图片生成需要时间,加载路径却不需要,导致生成的图片加载不上。 延时加载 你的是按DIV 布局先后来加载 左右布局时 左边 没完成 右边是加载不出来的最好是 横向布局 http://download.csdn.net/detail/wwfgu00ing/2563888 好像有一个叫jquery lazy的插件。可以解决。 基于jQuery的 lazyload 可以完美解决这个问题,很容易使用的。 用jquery的preload$.preloadImages = function() { for (var i = 0; i<arguments.length; i++) { img = new Image(); img.src = arguments[i]; }}$.preloadImages ( "path_to_image_array", "path_to_image_array", "path_to_image_array"); js放在body最后,图片能延迟加载就延迟。 //缩略图jQuery.fn.LoadImage=function(scaling,width,height,loadpic){ if(loadpic==null)loadpic="../images/msg_img/loading.gif";return this.each(function(){ var t=$(this); var src=$(this).attr("src") var img=new Image(); img.src=src; //自动缩放图片 var autoScaling=function(){ if(scaling){ if(img.width>0 && img.height>0){ if(img.width/img.height>=width/height){ if(img.width>width){ t.width(width); t.height((img.height*width)/img.width); }else{ t.width(img.width); t.height(img.height); } } else{ if(img.height>height){ t.height(height); t.width((img.width*height)/img.height); }else{ t.width(img.width); t.height(img.height); } } } } } //处理ff下会自动读取缓存图片 if(img.complete){ autoScaling(); return; } $(this).attr("src",""); var loading=$("<img alt=\"加载中...\" title=\"图片加载中...\" src=\""+loadpic+"\" />"); t.hide(); t.after(loading); $(img).load(function(){ autoScaling(); loading.remove(); t.attr("src",this.src); t.show(); //$('.photo_prev a,.photo_next a').height($('#big-pic img').height()); }); });} 小女子弱问php调用c语言的问题 寻求网站后台如何设立权限 php开发 框架问题?求高手 怎么获取新浪点击链接过来的来源路径呢?? thinkphp model验证不得行 如何搭建PHP 能输入RSS 织梦的留言板模板页中怎么能将数据库中的数据给调出来....经过好几次尝试都失败了... php怎样把数据库数据循环绑定到一个八行四列的表格里面去呢,知道的老师请说一下思路,谢谢 求PHP如何获取访问者的域名 求助:PHP内存溢出问题Fatal error: Out of memory swfupload上传完后显示500错误
左右布局时 左边 没完成 右边是加载不出来的最好是 横向布局
for (var i = 0; i<arguments.length; i++) {
img = new Image();
img.src = arguments[i];
}
}
$.preloadImages (
"path_to_image_array",
"path_to_image_array",
"path_to_image_array"
);
//缩略图
jQuery.fn.LoadImage=function(scaling,width,height,loadpic){
if(loadpic==null)loadpic="../images/msg_img/loading.gif";
return this.each(function(){
var t=$(this);
var src=$(this).attr("src")
var img=new Image();
img.src=src;
//自动缩放图片
var autoScaling=function(){
if(scaling){
if(img.width>0 && img.height>0){
if(img.width/img.height>=width/height){
if(img.width>width){
t.width(width);
t.height((img.height*width)/img.width);
}else{
t.width(img.width);
t.height(img.height);
}
}
else{
if(img.height>height){
t.height(height);
t.width((img.width*height)/img.height);
}else{
t.width(img.width);
t.height(img.height);
}
}
}
}
}
//处理ff下会自动读取缓存图片
if(img.complete){
autoScaling();
return;
}
$(this).attr("src","");
var loading=$("<img alt=\"加载中...\" title=\"图片加载中...\" src=\""+loadpic+"\" />");
t.hide();
t.after(loading);
$(img).load(function(){
autoScaling();
loading.remove();
t.attr("src",this.src);
t.show();
//$('.photo_prev a,.photo_next a').height($('#big-pic img').height());
});
});
}