function ViewImg()
{
document.getElementById('preImg').src=document.getElementById('FileUpload1').value;
}
window.onload=function()
{
if(navigator.userAgent.indexOf("MSIE")>0)
{
document.getElementById('FileUpload1').attachEvent("onpropertychange",ViewImg);
}
if(navigator.userAgent.indexOf("Firefox")>=0)
{
document.getElementById('FileUpload1').addEventListener("oninput",ViewImg, false);
}
}
我想实现图片预览功能 在FF中oninput不能用 如果用change图片控件不见了 各位高手有没有好的解决方法 谢谢!
<img alt="" src="../NewsImg/wu.jpg" style="width:200px; height:200px" id="preImg"/>
{
document.getElementById('preImg').src=document.getElementById('FileUpload1').value;
}
window.onload=function()
{
if(navigator.userAgent.indexOf("MSIE")>0)
{
document.getElementById('FileUpload1').attachEvent("onpropertychange",ViewImg);
}
if(navigator.userAgent.indexOf("Firefox")>=0)
{
document.getElementById('FileUpload1').addEventListener("oninput",ViewImg, false);
}
}
我想实现图片预览功能 在FF中oninput不能用 如果用change图片控件不见了 各位高手有没有好的解决方法 谢谢!
<img alt="" src="../NewsImg/wu.jpg" style="width:200px; height:200px" id="preImg"/>
window.onload=function() {
if(window.ActiveXObject) {
document.getElementById('FileUpload1').attachEvent("onchange",ViewImg);
}
else
document.getElementById('FileUpload1').addEventListener("change",ViewImg, false);
}
onchange 是可以的不过 ff 下预览图片 是很困难的不像IE 那样可以获得文件的全路径 它只能获得文件名 ,所以 想显示客户端的文件 是行不通的
IE下可以取得本地文件的路径
但FF下不能取得本地文件路径,所以FF下失败,并非oninput的原因
这是无法解决的