<form name="form5" >
<input type="file" name="file5" />
</form>
<script type="text/javascript">
function preview5(){
var x = document.getElementById("file5");
 if(!x || !x.value) return;
var patn = /\.jpg$|\.jpeg$|\.gif$/i;
if(patn.test(x.value)){ 
var y = document.getElementById("img5");
if(y){
y.src = "file://localhost/" + x.value;
}else{
var img=document.createElement("img");      img.setAttribute("src","file://localhost/"+x.value);
img.setAttribute("width","120");
img.setAttribute("height","90");
img.setAttribute("id","img5");
document.getElementById("form5").appendChild(img);
 }
}else{
alert("您选择的似乎不是图像文件。");
}}
</script> 

本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/8483.htm

相关文章:

  • 2021-06-25
  • 2022-12-23
  • 2021-10-27
  • 2021-07-12
  • 2021-12-05
  • 2021-12-31
  • 2021-08-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案