Upload pictures Live display compatible IE11

Source: Internet
Author: User

Html:

<style type= "Text/css" >
. imgonloadwrap{width:150px; height:200px;}
#img1 {width:150px; height:200px;}
</style>

<div class= "Imgonloadwrap" >

</div>

<input type= "File" style= "width:10px;" size= "1" class= "btn_add_pic" id= "file" name= "file" onchange= "upimg (This)"/ >

Js:

  

function upimg (obj) {
var $file = obj;

Note: This method ie11 incompatible var imgfile = obj.files[0];

Replace with: var fileobj = $file [0];
var fileobj = $file [0];
var windowurl = window. URL | | Window.webkiturl;
var Dataurl;
var $img = $ ("#img1");
if (fileobj && fileobj.files && fileobj.files[0]) {
Dataurl = Windowurl.createobjecturl (Fileobj.files[0]);
$img. attr (' src ', dataurl);
}else{
$ ('. Imgonloadwrap img '). Remove ();
var htmlstr = ';
Htmlstr + = ' ";
$ ('. Imgonloadwrap '). Append (HTMLSTR);
Dataurl = $file. Value;
var imgobj = document.getElementById ("Img1");
ImgObj.style.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (Sizingmethod=scale)";
ImgObj.filters.item ("DXImageTransform.Microsoft.AlphaImageLoader"). src = dataurl;

}
}

Upload pictures Live display compatible IE11

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.