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

推荐订阅源

J
Java Code Geeks
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
腾讯CDC
D
Docker
The Cloudflare Blog
量子位
爱范儿
爱范儿
L
LangChain Blog
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Vercel News
Vercel News
MyScale Blog
MyScale Blog

博客园 - wd900

Word 2007 发布测试 开源游戏引擎及游戏 [转]C# Regex 深入正则表达式 [转]从微软的sample中抠出的代码着色类 arcgis 操作 3个本地加密用的js文件,MD4 , MD5, SHA-1 silverlight MultiScaleImage 电子地图 公交查询合理性问题 [转贴]公交换乘简单算法 地址 QQ记录 [转]button样式 flash 的图片导航,来自www.o.cn 临时保存 svn XML学习资料 单元测试(转) http://www.codeplex.com/dasBlog/Release/ProjectReleases.aspx?ReleaseId=12829 [转]c#的一些技巧
[转]javascript实现缩略图
wd900 · 2008-06-29 · via 博客园 - wd900

来自:http://www.yiji.com/DotNet/283974/361418/

一段javascript实现缩略图的,如下
<script  language="javascript">

//显示缩略图
function DrawImage(ImgD,width_s,height_s){
/*var width_s=139;
var height_s=104;
*/
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>=width_s/height_s){
if(image.width>width_s){
ImgD.width=width_s;
ImgD.height=(image.height*width_s)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>height_s){
ImgD.height=height_s;
ImgD.width=(image.width*height_s)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
/*else{
ImgD.src="";
ImgD.alt=""
}*/
}
</script>

调用时,<img src="../memberphoto/<%=picpath%>" align="middle" onload="DrawImage(this,200,200)"></div>