Ben a écrit :
>
But firefox errors console write that getWidth is not a valid function
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="http://i11.ebayimg.com/01/i/000/ed/13/575b_1.JPG" alt="" id="V_1"
onload="alert(this.width+' '+this.height);">
<img src="http://i16.ebayimg.com/01/i/000/ed/13/562b_1.JPG" alt="" id="V_2">
<img src="http://i3.ebayimg.com/03/i/000/e2/fe/aa08_1.JPG" alt="" id="V_3">
size of image #:
<select
onclick="alert(getSize('V_'+(+this.selectedIndex+1 )).join(' '))">
<option>1
<option>2
<option>3
</select>
</html>
--
sm