Javascript上传&预览图像不工作的IE
Javascript upload & previews image not working on IE
我找到了一个脚本,可以让我上传一个<input type="file">
的图像,当用户加载图片时,它会在<div>
中预览,这在Chrome en FF上完美地工作,但IE根本不做任何事情…我不知道问题出在哪里,也许这里有人能帮助我:)
<div id="Step_06_Content_Prev_Img_1" class="Step_06_Content_Prev_Img_1">
<div id="Pic_1" class="Pic_1">
<span> Foto 1 : </span>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input name="file_1" type="file" onchange="changePic_1(this);" />
<div id="Img_1_" class="Img_1_1">
<img id="Img_1" class="Img_1" alt="Geen afbeelding geselecteerd!"/>
</div>
</div>
</div>
<div id="Pic_2" class="Pic_2">
<span> Foto 2 : </span>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input name="file_2" type="file" onchange="changePic_2(this);" />
<div id="Img_1_" class="Img_1_1">
<img id="Img_2" class="Img_2" alt="Geen afbeelding geselecteerd!" />
</div>
</div>
JavaScript:
function changePic_1(input)
{
if(input.files && input.files[0])
{
var reader = new FileReader();
reader.onload = function (e)
{
$('#Img_1').attr('src', e.target.result).width("180px").height("180px");
document.getElementById("Img_1").style.display = 'block';
document.getElementById("Img_1_Text").style.display = 'none';
document.getElementById("Img_1").style.visibility = "visible";
};
reader.readAsDataURL(input.files[0]);
}
}
function changePic_2(input)
{
if (input.files && input.files[0])
{
var reader = new FileReader();
reader.onload = function (e)
{
$('#Img_2').attr('src', e.target.result).width("180px").height("180px");
document.getElementById("Img_2").style.display = 'block';
document.getElementById("Img_2_Text").style.display = 'none';
document.getElementById("Img_2").style.visibility = "visible";
};
reader.readAsDataURL(input.files[0]);
}
}
请参考以下链接了解FileReader
的兼容性http://caniuse.com/filereader我认为fileReader()与您的IE版本不兼容,这就是为什么您没有得到任何错误,因为它不识别fileReader()函数
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- 点击选择Div不在IE上工作
- 如何编写在Chrome和IE中正常工作的JavaScript
- Target=_blank don'我不在mozilla和IE工作
- 如何隐藏空<span>在IE中使用javascript.(注意,在其他浏览器中工作正常)
- 读取在具有IE的工作程序中生成的对象URL
- Json到CSV下载,可以在chrome中工作,但不能在IE浏览器中工作
- jQUery Code没有'我不在IE工作
- 为什么这个书签脚本是't在IE工作
- 类构造函数super()没有'我不在IE工作
- JavaScript onclick在IE 9中工作两次,然后停止
- HTML5视频无法在chrome上工作,在服务器上托管后的IE,mov文件中的视频(quicktime格式)
- JSSOR转盘滑块在IE中不工作
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- onmousemove=null不会'我不在IE工作
- Javascript/AAJAX在Opera中不起作用,在FF/IE/Chrome中完美工作
- execCommand('另存为',true,'data.csv');不在IE工作
- 我的剧本赢了'不能在IE中工作(甚至9)?修改复制文本的简单javascript
- 纯Javascript: onClick切换行/图像:Firefox/Chrome -工作:IE -不工作
- jQuery菜单不工作ie(文档模式:怪癖)