惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 没剑

一段实现页面上的图片延时加载的js 失业了,别人不会告诉你的10件事 正确的SWOT分析方法(转) 界面内容优化的层次(转) 常用的CSS命名规则 jq插件之仿“卓越亚马逊”首页弹出菜单效果 实现firebird的Embedded模式(.net 3.5) Interbase/Firebird的SQL语法(收藏) mvc preview 2中,找到的一段表单数据填充实体的函数 jquery插件:web2.0分格的分页脚,可用于ajax无刷新分页 jquery插件:任意位置浮动固定层(09-11-05更新插件) jquery调用WebService和WebService输出JSON 兼容ie firefox 半透明效果 再次发布一个jq的下拉框式日期选择插件 dateSelector ~ 发布一个jQuery做的导航菜单的插件 submenu js让网页标题闪动效果(记) 关于接口使用getType的方法的问题 终于找到个可以在sql2000下用的正则啦,哈哈 定时删除sql中睡眠的进程 - 没剑 - 博客园
jq图片预加载+自动等比例缩放插件
没剑 · 2008-06-23 · via 博客园 - 没剑

/*
**************图片预加载插件******************
///作者:没剑(2008-06-23)
///http://regedit.cnblogs.com

///说明:在图片加载前显示一个加载标志,当图片下载完毕后显示图片出来
可对图片进行是否自动缩放功能
此插件使用时可让页面先加载,而图片后加载的方式,
解决了平时使用时要在图片显示出来后才能进行缩放时撑大布局的问题
///参数设置:
scaling     是否等比例自动缩放
width       图片最大高
height      图片最大宽
loadpic     加载中的图片路径

*/
jQuery.fn.LoadImage
=function(scaling,width,height,loadpic){
    
if(loadpic==null)loadpic="load3.gif";
    
return this.each(function(){
        
var t=$(this);
        
var src=$(this).attr("src")
        
var img=new Image();
        
//alert("Loading")
        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){
            
//alert("getToCache!");
            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();
            
//alert("finally!")
        });
        
    });
}

使用说明:
$("div img").LoadImage(true,120,90);

效果如下:

欢迎大家交流使用心得