<script type="text/javascript">
var flag=false;
function DrawImage(ImgD){
var p_w_picpath=new Image();
var iwidth = 186; //定义允许图片宽度
var iheight = 126; //定义允许图片高度
p_w_picpath.src=ImgD.src;
if(p_w_picpath.width>0 && p_w_picpath.height>0){
flag=true;
if(p_w_picpath.width/p_w_picpath.height>= iwidth/iheight){
if(p_w_picpath.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(p_w_picpath.height*iwidth)/p_w_picpath.width;
}else{
ImgD.width=p_w_picpath.width;
ImgD.height=p_w_picpath.height;
}
ImgD.alt=p_w_picpath.width+"×"+p_w_picpath.height;
}
else{
if(p_w_picpath.height>iheight){
ImgD.height=iheight;
ImgD.width=(p_w_picpath.width*iheight)/p_w_picpath.height;
}else{
ImgD.width=p_w_picpath.width;
ImgD.height=p_w_picpath.height;
}
ImgD.alt=p_w_picpath.width+"×"+p_w_picpath.height;
}
}
}
</script>
调用方法:
<img src="../**.JPG" style="border:none" />
略缩图代码
转载上一篇:PDF在网页中显示
下一篇:设为首页VS加入收藏

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
对以前的改进MFC略缩图控件改进
以前写了一篇日记, 显示略缩图,见《自绘列表框控件显示略缩图----再稍微改进点点。。
mfc delete file image 控件 -
自绘列表框控件显示略缩图----再稍微改进点点。。
每天思考一点无聊的问题,又是接上一篇日记
notifications image colors processing windows