1
有什麼辦法可以在IE中實現fileReader()。我搜查了很多,但沒有找到任何解決方案。這是我的代碼,我試圖實現它。它在Firefox和Chrome中工作正常,但它不在IE8和IE9中工作。上傳圖片之前的圖片預覽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>
你是什麼意思'不工作'?你有任何錯誤信息? –
thnx回覆其workin在Firefox和鉻,但在ie圖像預覽沒有顯示我serched在網上很多,但沒有得到NY解決方案... –