`
yunmoxue
  • 浏览: 289387 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

FireFox3 IE8 图片预览

    博客分类:
  • ajax
阅读更多
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");
	});
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics