zoukankan      html  css  js  c++  java
  • js实现缩略图

    <script  language="javascript">

    //显示缩略图
    function DrawImage(ImgD,width_s,height_s){
    /*var width_s=139;
    var height_s=104;
    */
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>=width_s/height_s){
    if(image.width>width_s){
    ImgD.width=width_s;
    ImgD.height=(image.height*width_s)/image.width;
    }else{
    ImgD.width=image.width;
    ImgD.height=image.height;
    }
    }
    else{
    if(image.height>height_s){
    ImgD.height=height_s;
    ImgD.width=(image.width*height_s)/image.height;
    }else{
    ImgD.width=image.width;
    ImgD.height=image.height;
    }
    }
    }
    /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
    }
    </script>


    调用
    <div><img src="图片" align="center" onload="DrawImage(this,200,200)"></div>
  • 相关阅读:
    杂项_做个游戏(08067CTF)
    杂项_白哥的鸽子
    杂项_隐写3
    杂项_come_game
    杂项_多种方法解决
    杂项_闪的好快
    杂项_隐写2
    杂项_宽带信息泄露
    杂项_啊哒
    杂项_猜
  • 原文地址:https://www.cnblogs.com/zijinguang/p/1224779.html
Copyright © 2011-2022 走看看