JS实现兼容IE6、IE7、IE8的图片上传前预览效果

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>兼容IE6、IE7、IE8的图片上传前预览效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代码加到<head>与</head>之间-->
<script type="text/javascript" language="javascript">
function PreviewImg(imgFile){
 var newPreview=document.getElementById("newPreview");
 var imgDiv=document.createElement("div");
 document.body.appendChild(imgDiv);
 imgDiv.style.width="118px";imgDiv.style.height="127px";
 imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
 imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=imgFile.value;
 newPreview.appendChild(imgDiv);
 var showPicUrl=document.getElementById("showPicUrl");
 showPicUrl.innerText=imgFile.value;
 newPreview.style.width="80px";
 newPreview.style.height="60px";
}
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<div id="newPreview"></div>
<div id="showPicUrl"></div>
<hr><br>
请选择图片:<input type="file" name="file" οnchange="javascript:PreviewImg(this);">
</body>
</html>
发布了93 篇原创文章 · 获赞 2 · 访问量 10万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章