DotNet

DotNet

C#、VB.NET、asp.net学习、开发,.Net平台项目管理与开发,经验交流以及代码探讨。 [查看全部]

大本营地址:http://www.yiji.com/DotNet/ [复制地址] [加入收藏夹]

您的当前位置:蚁集网 > 首页 > Asp.Net交流 > javascript实现缩略图

javascript实现缩略图

夏天的风 职位:营友

2007-10-8 发表

本文专长值:0 | 评论:0

快马加鞭
152
进士
3191
初出江湖
130
一穷二白
20
汗水 专长 影响 金币

一段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>

 

 
0

作者:夏天的风

我来说两句 显示全部相关评论(0)条

发表评论

您目前是匿名回复 登录 | 注册

匿名发表

大本营最新图片