zoukankan      html  css  js  c++  java
  • 上传图片时JS自动显示图片

    Code
    <HTML>
    <META http-equiv=Content-Type content="text/html; charset=utf-8">
    <HEAD>
    <TITLE> Test Page </TITLE>

    </HEAD>

    <BODY>
    <script>
    function preview(imgFile,num)
    {
        
    //预览代码,支持 IE6、IE7。
        var newPreview = document.getElementById("preview1");
      
        
    var t ;
        
    if(document.all) //IE
        t = imgFile.value;
        
    else
        t 
    = imgFile.files[0].getAsDataURL(); //FF
        newPreview.style.backgroundImage = "url(" + t + ")";//imgFile.value;
        newPreview.style.width = "108px";
        newPreview.style.height 
    = "130px";
        newPreview.style.display 
    = "block";
    }

    </script>
    <input type="file" onchange='ShowImg(this)' />

    <div id="preview1" style="border:1px solid #FFCC00; 108px; height:130px;display:block" >

    </div>
    <script>function ShowImg(o)
    {  
    //var Browser_Agent=navigator.userAgent;
    //
    if(Browser_Agent.indexOf("Firefox")!=-1)
    //
    {
    //
    火狐使用
      //  document.getElementById("idImg").src=o.files[0].getAsDataURL();
      //  document.getElementById("idImg").style.display = "block";
      // }
    //
    else
    //
    {
          preview(o,1);
        
    //}
    </script>


    </BODY>
    </HTML>

    aliyun活动 https://www.aliyun.com/acts/limit-buy?userCode=re2o7acl
  • 相关阅读:
    pair和map
    lower_bound( )和upper_bound( )
    P1886 滑动窗口 /【模板】单调队列
    数的度(数位dp)
    最小生成树
    刷题-力扣-1052. 爱生气的书店老板
    刷题-力扣-766. 托普利茨矩阵
    刷题-力扣-28. 实现 strStr()
    刷题-力扣-697. 数组的度
    刷题-力扣-1004. 最大连续1的个数 III
  • 原文地址:https://www.cnblogs.com/wangbin/p/1505663.html
Copyright © 2011-2022 走看看