zoukankan      html  css  js  c++  java
  • 转载: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>

  • 相关阅读:
    【杭电】[4883]TIANKENG’s restaurant
    【杭电】[4883]TIANKENG’s restaurant
    【POJ】[1423]Big Number
    【POJ】[1423]Big Number
    【杭电】[1280]前m大的数
    【杭电】[1280]前m大的数
    【杭电】[1576]A/B
    【杭电】[1576]A/B
    [leetcode]346. Moving Average from Data Stream滑动窗口平均值
    [leetcode]99. Recover Binary Search Tree恢复二叉搜索树
  • 原文地址:https://www.cnblogs.com/lraa/p/3282151.html
Copyright © 2011-2022 走看看