图片缩放js

<script language=javascript>
function propersize(a)
{

var width1=images2.width;           
var height1=images2.height;           
var width2=660;           
var height2=500;           
var h=height1/height2;
var w=width1/width2;
if(height1<height2&&width1<width2)
{
  images1.height=height1;           
  images1.width=width1;          
}
else
{
  if(h>w)
  {
   images1.height=height2;         
   images1.width=width1*height2/height1;          
  }
  else
  {
   images1.width=width2;          
   images1.height=height1*width2/width1;         
  }
}
}
</script>
<script language="javascript">
var count = 10;
function resizeimg(oImage)
{
count = Counting(count);
Resize(oImage,count);
return false;
}
function Counting(newzoom){
if (event.wheelDelta >= 120)
newzoom++;
else if (event.wheelDelta <= -120)
newzoom--;
if (newzoom<2) newzoom=2; ////只允许缩小到20%
if (newzoom>30) newzoom=30; ////只允许放大到300%

return newzoom;
}
function Resize(oImage,newzoom){
if(oImage.width*newzoom*0.1<=650 && oImage.height*newzoom*0.1<=500)
{
oImage.style.zoom = newzoom + '0%';
count=newzoom;
}
}
</script>

posted @ 2006-10-13 16:33  ddr888  阅读(727)  评论(0编辑  收藏  举报