62,025
社区成员
发帖
与我相关
我的任务
分享
//方法。图片那边onload = DrawI(this); IE中第一次不行,刷新一下就可以了.CSS就不贴了。不喜欢
//此方法为网上拷贝的。上网搜下,很多都是这个方法。应该不是方法本身问题。而是IE6哪里不一样了。。
function DrawImage(ImgD){
var image=new Image();
var iwidth = 250; //定义允许图片宽度
var iheight = 250; //定义允许图片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}