zoukankan      html  css  js  c++  java
  • 图片缩放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>

  • 相关阅读:
    深拷贝与浅拷贝
    ifconfig命令不可用
    多边形裁剪问题
    ps aux命令后的内容
    STL sort的危险之处
    jdk与jre的区别
    #与##的用法
    投影选择的一般原则
    关于函数中内存操作
    js生成新加坡的NRIC号码
  • 原文地址:https://www.cnblogs.com/ddr888/p/528394.html
Copyright © 2011-2022 走看看