• 转载:js实现上传图片时 点击浏览后 就可以看到缩略图 很实用


    转载网址:http://blog.sina.com.cn/s/blog_6094f04d0100o6kj.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head>

    <SCRIPT   LANGUAGE="JavaScript">     

    var   flag=false;   

    function   DrawImage(ImgD){ 

        var image=new   Image();

        image.src=ImgD.src;

        if(image.width>0   &&   image.height>0){ 

        flag=true;      

        if(image.width>300 || image.height>200)     {

          ImgD.width=image.width/2; 

                     ImgD.height=image.height/2;

          ImgD.alt=image.width+"×"+image.height;

        }    else    {

          ImgD.width=image.width;  

          ImgD.height=image.height; 

                  ImgD.alt=image.width+"×"+image.height; 

        }  

      }   

    }  

    function   mainChange(Value){ 

      flag=false;

      document.all.mainimage.width=5; 

      document.all.mainimage.height=5;

      document.all.mainimage.alt=""; 

      document.all.mainimage.src=Value; 

       document.all.maindiv.style.display=''; 

    }

    </SCRIPT>

    <TABLE   border="0">

      <TBODY>

        <tr> 

          <td   height="22"   colspan="5">        

            top:<input   type="file"   name="up1"   style="300"   class="textbox"  onChange="javascript:mainChange(this.value);"> 

          </td>                

        </tr>        

      </TBODY>    

    </TABLE>        

    <table height="78"   border="0"   cellpadding="0"   cellspacing="0">       

      <tr>                

        <td  >

          <div   id="maindiv" style="display:none">      

            <IMG   id=mainimage height=70 width=20 src="" onload="javascript:DrawImage(this);"   >      

          </div>

        </td>               

      </tr>        

    </table>

    <body> </body>

    </html>

  • 相关阅读:
    学习的原动力
    “六顶思考帽”给我的启示
    关于DataSet与Strongly typed DataSet几点思考(原创)
    设计模式之Singleton和Factory
    CentOS修改网络配置
    Proxmox VE(PVE)安装教程
    CentOS开启SELinux导致samba无法访问的解决办法
    nano编辑器使用教程
    CentOS 如何挂载硬盘
    PVE硬盘直通
  • 原文地址:https://www.cnblogs.com/lraa/p/3282151.html
Copyright © 2020-2023  润新知