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