标签:ie11 mic files nbsp input value item ntb microsoft
html:
<style type="text/css">
.imgOnloadWrap{ width: 150px; height: 200px;}
#img1{ width: 150px; height: 200px;}
</style>
<div class="imgOnloadWrap">
<img id="img1" name="fileimage" src="<c:url value=‘/${bean.fileUrl }‘ />" />
</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;
注:这种方式ie11不兼容 var imgFile = obj.files[0];
替换成: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 += ‘<img id="img1" src=""/>‘;
$(‘.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;
}
}
标签:ie11 mic files nbsp input value item ntb microsoft
原文地址:https://www.cnblogs.com/jiaobaobao/p/8875235.html