js图片预览ie9下报错
报错位置
js代码
function previewImage(file,sort)
{
var MAXWIDTH = 50;
var MAXHEIGHT = 50;
var div = document.getElementById('preview_'+sort);
if (file.files && file.files[0])
{
div.innerHTML = '<img id=imghead_'+sort+'>';
var img = document.getElementById('imghead_'+sort);
img.onload = function(){
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
img.width = MAXWIDTH;
img.height = MAXHEIGHT;
/*img.width = rect.width;
img.height = rect.height;
img.style.marginLeft = rect.left+'px';
img.style.marginTop = rect.top+'px';*/
}
var reader = new FileReader();
reader.onload = function(evt){img.src = evt.target.result;}
reader.readAsDataURL(file.files[0]);
}
else
{
var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
file.select();
file.blur();
var src = document.selection.createRange().text;
div.innerHTML = '<img id="imghead_'+sort+'">';
var img = document.getElementById('imghead_'+sort);
//var img = new Image();
//img.src = src;
img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
div.innerHTML = "<div class='goods_img' id='divhead' style='width:"+MAXWIDTH+"px;height:"+MAXHEIGHT+"px;"+sFilter+src+"\"'></div>";
}
}