is it possible to get an image to resize if it exceeds certain size limits without having to press a button? the problem as i see it is that since it takes time to load an image, if the script is run as the page loads, the image.width and image.height are undefined, meaning that I can't see if they are out of the boundaries and also I can't resize them in proprtion. this it the script i've got which doesn't work:
i've tried putting this function both in the body onLoad and in the <body></body> tags (without the function {} of course) but none of it seems to work.
is there some way that I can get it to be called after the image loads?
Code:
function imgsizer{
var imgs = document.images;
var imgHeight = imgs[0].Height;
var imgWidth = imgs[0].Width;
var scale;
if (imgWidth > 800){
scale = 800 / imgWidth;
imgs[0].Height = imgHeight * scale;
imgs[0].width = 800;
}
if (imgs[0].Height > 600){
scale = 600 / imgHeight;
imgs[0].width = imgWidth * scale;
imgs[0].height = 600;
}
}
i've tried putting this function both in the body onLoad and in the <body></body> tags (without the function {} of course) but none of it seems to work.
is there some way that I can get it to be called after the image loads?