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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章