Beck
10-27-2002, 10:56 PM
Two questions, really:
1) I want to initialize image objects as the page loads. I know it starts something like the folllowing:
var myImg = new Image ();
is there a way to intialize it with the image name and it's associated height and width attributes such as:
var myImg = new Image ("img.gif",25,105);
Or at least with just the image name? I'm trying to get it done in one line of code instead of assigning the source, then height, then the width, taking four lines instead. On top of that, if anyone can provide a link to working with image objects, that would be the right direction.
2) Given an image name, and wanting to build an image object, is there a way to know the actual height and width of the image? This almost defeats the purpose of my first question, but I'm hoping to be able, given the image, to determine how big in pixel size that it is. I'm guessing the following is a longshot:
var myImg = new Image ("userinput.gif");
var myImgheight = myImg.height;
var myImgwidth = myImg.width;
3) Okay, thought of a third one while I was at it. What are my even handlers associated with images? Can I check when it loads, unloads, aborts, errors, etc?
Again, any links are appreciated, and inside thoughts from a guru are golden.
Thanks in advance.
1) I want to initialize image objects as the page loads. I know it starts something like the folllowing:
var myImg = new Image ();
is there a way to intialize it with the image name and it's associated height and width attributes such as:
var myImg = new Image ("img.gif",25,105);
Or at least with just the image name? I'm trying to get it done in one line of code instead of assigning the source, then height, then the width, taking four lines instead. On top of that, if anyone can provide a link to working with image objects, that would be the right direction.
2) Given an image name, and wanting to build an image object, is there a way to know the actual height and width of the image? This almost defeats the purpose of my first question, but I'm hoping to be able, given the image, to determine how big in pixel size that it is. I'm guessing the following is a longshot:
var myImg = new Image ("userinput.gif");
var myImgheight = myImg.height;
var myImgwidth = myImg.width;
3) Okay, thought of a third one while I was at it. What are my even handlers associated with images? Can I check when it loads, unloads, aborts, errors, etc?
Again, any links are appreciated, and inside thoughts from a guru are golden.
Thanks in advance.