`

Jquery实现图片 上传同步预览 兼容火狐各种浏览器

阅读更多

 

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {
$('#img_prev')
.attr('src', e.target.result)
.width(150)
.height(200);
};

reader.readAsDataURL(input.files[0]);
}
}
</script>

<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
<input type='file' onchange="readURL(this);" />
<img id="img_prev" src="#" alt="your image" />
</body>
</html>

  更多内容 请参考我的个人博客 http://ismartstudio.com/

 

 

1
2
分享到:
评论
4 楼 guangqiang 2012-10-24  
myfoot 写道
IE8 不可用

http://css-tricks.com/ajax-image-uploading/
3 楼 guangqiang 2012-10-24  
myfoot 写道
IE8 不可用

相关文章建议你采用http://blog.csdn.net/fengxing2009/article/details/7298883
2 楼 guangqiang 2012-10-24  
myfoot 写道
IE8 不可用

IE 和safari建议用ajax
1 楼 myfoot 2012-10-24  
IE8 不可用

相关推荐

Global site tag (gtag.js) - Google Analytics