Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
How to get Natural image width and height?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="SAM, post: 4971003"] Ben a écrit : did you code it ? or do you use prototype's library ? <html> <style type="text/css"> img { width: 100px; } </style> <script type="text/javascript"> function getSize(imgId) { var i = document.getElementById(imgId); var siz = function(what) { what.widss = what.naturalWidth? what.naturalWidth : what.width; what.heigt = what.naturalHeight? what.naturalHeight : what.height; return what; } i = siz(i); if(!i.widss) setTimeout(function(){getSize(imgId)},200); else return [i.widss, i.heigt]; } window.onload = function() { alert(getSize('V_2').join(' ')); } </script> All images displayed in 100px width : <img src="[URL]http://i11.ebayimg.com/01/i/000/ed/13/575b_1.JPG[/URL]" alt="" id="V_1" onload="alert(this.width+' '+this.height);"> <img src="[URL]http://i16.ebayimg.com/01/i/000/ed/13/562b_1.JPG[/URL]" alt="" id="V_2"> <img src="[URL]http://i3.ebayimg.com/03/i/000/e2/fe/aa08_1.JPG[/URL]" alt="" id="V_3"> size of image #: <select onclick="alert(getSize('V_'+(+this.selectedIndex+1)).join(' '))"> <option>1 <option>2 <option>3 </select> </html> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
How to get Natural image width and height?
Top