js
Code
//缩放多张图片
function ZoomAllPicture(pictureid,setformatwidth,setformatheight)
{
//var allItem = document.getElementsByTagName("Img");
var formatwidth = parseInt(setformatwidth); //设定格式化宽度
var formatheight = parseInt(setformatheight); //设定格式化高度
var outwidth; //输出宽度
var outheight; //输出高度
var width; //原图片宽度
var height; //原图片高度
$("img[id="+pictureid+"]").each(function(i,n){
width = parseInt($(this).width());
height = parseInt($(this).height());
var rateWidth = formatwidth / width;
var rateHeight = formatheight / height;
if(rateWidth > rateHeight){
outheight = setformatheight;
outwidth = width * rateHeight;
}
else{
outheight = height * rateWidth;
outwidth = formatwidth
}
$(this).attr("width",outwidth);
$(this).attr("height",outheight);
});
}
//缩放多张图片
function ZoomAllPicture(pictureid,setformatwidth,setformatheight)
{
//var allItem = document.getElementsByTagName("Img");
var formatwidth = parseInt(setformatwidth); //设定格式化宽度
var formatheight = parseInt(setformatheight); //设定格式化高度
var outwidth; //输出宽度
var outheight; //输出高度
var width; //原图片宽度
var height; //原图片高度
$("img[id="+pictureid+"]").each(function(i,n){
width = parseInt($(this).width());
height = parseInt($(this).height());
var rateWidth = formatwidth / width;
var rateHeight = formatheight / height;
if(rateWidth > rateHeight){
outheight = setformatheight;
outwidth = width * rateHeight;
}
else{
outheight = height * rateWidth;
outwidth = formatwidth
}
$(this).attr("width",outwidth);
$(this).attr("height",outheight);
});
}
,这个送给你!