http://luolonghao.iteye.com/blog/1188020
$(document).ready(function(){ $("#upload_img").change(function(e){ if(this.files){ var file = this.files[0]; if(FileReader){ var oFReader = new FileReader(); oFReader.onload = function (oFREvent) { $("#img_review").attr("src",oFREvent.target.result); }; oFReader.readAsDataURL(file); }else{ $("#img_review").attr("src",file.getAsDataURL()); } }else if(navigator.userAgent.indexOf("MSIE 6.0")>=1){ $("#img_review").attr("src",this.value); }else if(navigator.userAgent.indexOf("MSIE 7.0")>=1 || navigator.userAgent.indexOf("MSIE 8.0")>=1){ var src = ''; this.select(); try { src = document.selection.createRange().text; } finally { document.selection.empty(); } src = src.replace(/[)'"%]/g, function(s){ return escape(escape(s)); }); img_review.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src=\"" + src + "\")"; } $("#img_review").css("display","block"); });});
相关资源:兼容最新firefox、chrome和IE的javascript图片预览实现代码