PDA

View Full Version : img object


gish
11-26-2002, 04:23 PM
any one here no the img object good enough to tell me what the basic sysntax to getting the height/width from an img when getting it from the database....understand the height/width is not a field the the.......

might be something like.... img.style.height??

i want to them in var
for example

var sHeight = "" + img.style.height
var sWidth = "" + img.style.width

thanks

G

brendandonhue
07-11-2003, 02:12 PM
var sHeight = img.height
var sWidth = img.width
Example of using/changing it here
http://mywebpages.comcast.net/brendandonhue/image.html
And if you needed to do this with multiple images, try something like this
<script type="text/javascript">
function getSize(image)
{
var sHeight = image.height;
var sWidth = image.width;
alert(sHeight + "x" + sWidth)
}
</script>
pic1.gif

tobymiller
01-21-2004, 05:37 PM
gish,

Be forewarned that this doesn't truly tell you what the width and height of an image is. It tells you what width and height the image was drawn at. Take these examples:




mypic_100x100.gif


mypic_100x100.gif


mypic_100x100.gif