<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
function imgMax(Imgid ,width,height)
{
//var width=200;
//var height=200;
img =new Img();
img.src=Imgid.src;
if ( img.width > width || img.height > height )
{
if ( img.width > img.height)
{
img.height = img.height*(width/img.width);
img.width = width;
}
else
{
img.width = img.width*(height/n.height);
img.height = height;
}
}
if (img.height < height )
{
img.style.paddingTop = ( height -img.height ) /2 + "px";
}
}
</script>
<title>图片的缩放</title>
</head>
<body>
<img onload ="imgMax(this ,200 ,200) src="D:\照片\亲戚2.jpg" id="pic">
</body>
</html>