Onelong

分享知识,与你一起进步......
RSS icon Home icon
  • JS预览客户端图片

    post by onelong / 2009-10-9 16:35 Friday [javascript]

    <html>
    <head>
    <style>
    #preview {
    width: 270px;
    height: 129px;
    }
    </style>
    <!--[if IE]>
    <style>
    #preview {
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);
    }
    </style>
    <![endif]-->
    <script>
    function preview(image)
    {
    if ("Microsoft Internet Explorer" == navigator.appName) {
    document.getElementById("image").style.display = "none";
    document.getElementById("preview").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = image.value;
    } else if ("Netscape" == navigator.appName){
    document.getElementById("image").src = image.files[0].getAsDataURL();
    } else {
    alert("Not Support!");
    }
    }
    </script>
    </head>
    <body>
    <input type="file" onChange="preview(this);" />
    <div id="preview">
    <img id="image" src="http://www.baidu.com/img/baidu_logo.gif" />
    </div>
    </body>
    </html>

    标签: javascript image
    引用地址:
     

    我要评论