Last Update:2017-08-24
Source: Internet
Author: User
Keywords
Web page production
Ajax
javascript
Web page effects upload picture preview (support Ie7,ie8,firefox)
<head> <meta http-equiv= "Content-type" content= "HTML; charset=gb2312"/> <title> Web effects upload picture preview </title> <script language= "Web Effects" > function ShowImage (Fileuploadid, Imgid) { if (document.getElementById (fileuploadid). Value!= "") { document.getElementById (imgid). style.display = "block" document.getElementById (imgid). src = GetPath (document.getElementById (Fileuploadid)); } } function getpath (obj) { if (obj) { if (Window.navigator.useragent.indexof ("MSIE") >= 1) { Obj.select (); Return Document.selection.createrange (). text; } else if window.Navigator.useragent.indexof ("Firefox") >= 1) { if (obj.files) {return Obj.files.item (0). Getasdataurl ();} return obj.value; } return obj.value; } }
</script> </head>
<body> <form enctype= "Multipart/form-data" > <label> <input type= "File" name= "file" id= "FID" Onmouseo tutorial ut= "showimage" (' FID ', ' viewimg '); > </label> <input name= "" type= "button" value= "Submit" > </form> <img src= "" id= "viewimg" > </div> </body> </html> Code two
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <html> <head> <title> New Document </title> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta name= "keywords" content= "" > <meta name= "description" content= "" > <script language= "Web Effects" > <!-- function showimg (obj) { var imgobj = document.getElementById ("Imgid"); IMGOBJ.SRC = Obj.value; } --> </script> </head>
<body> <input type= "file" onchange= "showimg (This)" ><BR> <img src= "" id= "Imgid"/> </body> </html> //code three
<html> <head> <meta http-equiv= "Content-type" content= "HTML; charset=gb2312 > <title> upload form with picture preview--111cn.net</title> <script> function Viewmypic (mypic,imgfile) { if (imgfile.value) { mypic.src=imgfile.value; Mypic.style.display= ""; mypic.border=1; } } </script> </head> <body> <center> <form > < Input name= "imgfile" type= "file" id= "Imgfile" size= "" onchange= "Viewmypic (showimg,this.form.imgfile);"/> <br/> </form> <img name= "showimg" id= "showimg" src= "style=" Display:none "alt=" "Preview picture"/> <br/> </div> <div style= "Display:none" > </div > </center> </body > </html>