<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>