废话不多说了,直接给大家贴js实现点击图片显示原图片的代码,具体代码如下所示:
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实现上传图片及时预览
图片上传本地预览 #preview{width:260px;height:190px;border:1px solid #000;overflow:hidden;} #imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);} /images/defaul.jpg'>



