<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
<!--
function PreviewImg(imgFile) {
var filevalue = imgFile.value;
var substr = filevalue.substring(filevalue.lastIndexOf("."), filevalue.length);
var fileFormat = substr.toLowerCase();
var key = true;
if ((fileFormat != '.jpg') && (fileFormat != '.gif') && (fileFormat != '.jpeg') && (fileFormat != '.png') && (fileFormat != '.bmp')) {
alert("请上传规定格式的图片,谢谢 !");
key = false;
imgFile.select();
imgFile.focus();
}
if (key) {
var newPreview = document.getElementById("newPreview");
var imgDiv = document.createElement("div");
newPreview.style.display = "";
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);
newPreview.style.width = "80px";
newPreview.style.height = "60px";
}
}
-->
</script>
</head>
<body>
<div >
<p>
<label for="photo">图片:</label>
<input id="imgPath" name="imgPath" type="file" size="20" onchange="javascript:PreviewImg(this);" />
<div id="newPreview" ></div>
</p>
</div>
</body>
</html>
当我第二次点击浏览 改变路径时,DIV中的图片也相应改变 该怎么做?急!!