Home >Web Front-end >JS Tutorial >js compatible Firefox method to obtain image width and height_javascript skills
The example in this article describes the method of obtaining the image width and height using js compatible with Firefox. Share it with everyone for your reference. The specific implementation method is as follows:
<!doctype html> <html> <head> <meta content="text/html; charset=GBK" http-equiv="Content-Type" /> <title>获取Image 宽高</title> </head> <body> <script> function newimage(obj) { a = new Image(); var objectURL = window.URL.createObjectURL(obj.files[0]); var img= document.getElementById('img') img.src = objectURL; a.src = objectURL; img.onload=function (){ alert(img.width); alert(img.height); } } </script> <input id="idcardfile" type="file" name="idcardfile" onchange="newimage(this)"/> <img id="img" style="display: none;"> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.