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
  • 相关阅读:
    (转) IOS ASI http 框架详解
    不是技术牛人 如何拿到IT巨头的Offer 来自作者: lsldd 来源: CSDN
    数据类型Block 粗解
    GCD的基本思想
    自定义Cell的 两种方法!
    全世界最幸运的我
    实现鸢尾花数据的读入
    Tensorflow2的基本用法
    6.17
    6.16
  • 原文地址:https://www.cnblogs.com/wangbin/p/1505663.html
Copyright © 2011-2022 走看看