The text of this article is not in this database — only its details are. Read it on the old site: Get the Width and Height of an Image using Javascript
2 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Mahesh LPosted Mar 30, 2010, 8:17 AM
Thanks. Is this possible to get more than 1 image dimensions and display them onmouseover event. like, <HTML><o:p></o:p> <HEAD><o:p></o:p> <TITLE></TITLE><o:p></o:p> <o:p></o:p> </HEAD><o:p></o:p> <o:p></o:p> <BODY><o:p></o:p> <img id="f1" src = "1.jpg" border="0"/> <p>Test</p> <img id="f2" src = "2.jpg" border="0"/> <p>Test</p> <img id="f3" src = "3.jpg" border="0"/> <p>Test</p> <p>Test</p> <p>Test</p> <p>Test</p> <img id="f4" src = "4.jpg" border="0"/> <o:p></o:p> <p>Test</p> </BODY><o:p></o:p> </HTML>
Binod SumanPosted Jun 4, 2009, 2:14 PM
I was searching a solution to get height and widht of an image using javascript. I got many but all those solution only worked when image present in browser cache. Finally I got one solution to get image height and width even image does not exist in browser cache. Just I want to share all of you. [code] <script type="text/javascript" language="javascript1.2"> var imgHeight; var imgWidth; function findHHandWW() { imgHeight = this.width;imgWidth = this.width;return true; } function showImage(imgPath) { var myImage = new Image(); myImage.name = imgPath; myImage.onload = findHHandWW; myImage.src = imgPath; } </script> [code] Thanks, Binod Suman http://binodsuman.blogspot.com/2009/06/how-to-get-height-and-widht-of-image.html