首页 > Web开发 > 详细

JS 图片点击显示原图片

时间:2015-11-26 19:26:02      阅读:232      评论:0      收藏:0      [点我收藏+]

function DrawImage(ImgD){
    var image = new Image();
    image.src=ImgD.src;
    var width = $(ImgD).attr("width");
    var height = $(ImgD).attr("height");
    if(width >100 && height>80){
        ImgD.width=100;  
        ImgD.height=80;
        ImgD.alt=image.width+"×"+image.height;
    }else{
        if(image.width>0 && image.height>0){
            flag=true;
            if(image.width>300 || image.height>200){
                ImgD.width=image.width/2;  
                ImgD.height=image.height/2;
                ImgD.alt=image.width+"×"+image.height;
            }else{
                ImgD.width=image.width;     
                ImgD.height=image.height;
                ImgD.alt=image.width+"×"+image.height;
            }
        }
    }
}

JS 图片点击显示原图片

原文:http://ouyangjun.blog.51cto.com/10284323/1717115

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!