J
Josselin
I am loading a group of items (urls of images to load) group.items
for each items I associate the filename and an <img> object on my page using :
....
var pair = new ImagePair(group.items);
....
function ImagePair( _file ) {
this.file = _file;
this.image = new Image();
this.image.width="0";
this.image.height="0";
document.body.appendChild(this.image);
}
then I want to check the image loading state of these images with a
loadImage_callback() function
....
(pair.image).onreadystatechange = loadImage_callback();
pair.image.src = group.items;
........
function loadImage_callback() {
// The loading state of some image has just updated
var obj = event.srcElement;
var group = _g_image_group;
// If the image has just loaded, update the count
if (obj.readyState == "complete")
group.numLoaded ++;
// Call imageupdate handler on group, if specified; otherwise call
imageupdate handler on document
if (group.imageupdate)
eval("group.imageupdate(group)");
else if (document.imageupdate)
eval("document.imageupdate(group)");
// If there are still images to load, schedule another callback
(condition isn't strictly
// necessary, since "complete" is the final stage of loading,
therefore when an image
// is "complete" it won't fire further readystatechange events)
if (group.numLoaded != group.numToLoad) {
obj.onreadystatechange = loadImage_callback();
}
}
........
upon run, I get a problem when I enter into the loadImage_callback() function :
my browser (Firefox) complains about the 'event.srcElement' , stating
that 'event' is not defined ...
what could be the trick ?
I am just a beginner using DOM, and progressing line by line ;-))
thansk for your help
for each items I associate the filename and an <img> object on my page using :
....
var pair = new ImagePair(group.items);
....
function ImagePair( _file ) {
this.file = _file;
this.image = new Image();
this.image.width="0";
this.image.height="0";
document.body.appendChild(this.image);
}
then I want to check the image loading state of these images with a
loadImage_callback() function
....
(pair.image).onreadystatechange = loadImage_callback();
pair.image.src = group.items;
........
function loadImage_callback() {
// The loading state of some image has just updated
var obj = event.srcElement;
var group = _g_image_group;
// If the image has just loaded, update the count
if (obj.readyState == "complete")
group.numLoaded ++;
// Call imageupdate handler on group, if specified; otherwise call
imageupdate handler on document
if (group.imageupdate)
eval("group.imageupdate(group)");
else if (document.imageupdate)
eval("document.imageupdate(group)");
// If there are still images to load, schedule another callback
(condition isn't strictly
// necessary, since "complete" is the final stage of loading,
therefore when an image
// is "complete" it won't fire further readystatechange events)
if (group.numLoaded != group.numToLoad) {
obj.onreadystatechange = loadImage_callback();
}
}
........
upon run, I get a problem when I enter into the loadImage_callback() function :
my browser (Firefox) complains about the 'event.srcElement' , stating
that 'event' is not defined ...
what could be the trick ?
I am just a beginner using DOM, and progressing line by line ;-))
thansk for your help