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

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

博客园 - 码 头

实测有效:Win11右键默认显示更多设置教程 netcore 并发锁 多线程中使用SemaphoreSlim HTML转义字符大全 .Net Core后台任务启停(BackgroundService) 常见的JavaScript的循环处理数据方法 Linux下.NET Core进程守护设置,解决SSH关闭后.NET Core服务无法访问的问题 记录 IIS 部署vue 项目步骤 AspNetCoreApi 跨域处理(CORS ) .NET CORE 使用Session报错:Session has not been configured for this application or request 小豆苗疫苗辅助搜索 日期函数(sql) c# DESEncrypt 加密、解密算法 汉字编码问题转换 二分法算法 MVC拦截器记录操作用户日志 最全的Resharper快捷键汇总 如何将数据库中的表导入到PowerDesigner中 修复IE9.0下PlaceHolder 属性问题js脚本 sql脚本查询日期时间段日期
图片javascript缩小
码 头 · 2016-07-15 · via 博客园 - 码 头
function SetSize(obj, width, height) 
{ 
myImage = new Image(); 
myImage.src = obj.src; 
if (myImage.width>0 && myImage.height>0) 
{ 
var rate = 1; 
if (myImage.width>width || myImage.height>height) 
{ 
if (width/myImage.width<height/myImage.height) 
{ 
rate = width/myImage.width; 
} 
else 
{ 
rate = height/myImage.height; 
} 
} 
if (window.navigator.appName == "Microsoft Internet Explorer") 
{ 
obj.style.zoom = rate; 
} 
else 
{ 
obj.width = myImage.width*rate; 
obj.height = myImage.height*rate; 
} 
} 
} 

用法: 


<img src="img/offer/41936519.jpg" border="0" style="zoom: 0.1" onload="SetSize(this, 80, 60)"/>