Image Object complete not accurate?

R

Rob T

I made an image slideshow with precaching that uses three overlapping
div tags that each contain an img tag that can be accessed using
getElementById(). If imgObj is my image object, I change imgObj.src to
the image URL and I'm checking imgObj.complete to see if it has been
loaded. The problem is that when I change an imgObj that previously
held an image, complete will be true immediately after imgObj.src has
been changed, regardless of whether it is loaded. Is there any way to
avoid this or is there a way to destroy the old image object before I
assign the new src URL?

Rob
 
R

Randy Webb

Rob T said the following on 11/2/2006 5:21 PM:
I made an image slideshow with precaching that uses three overlapping
div tags that each contain an img tag that can be accessed using
getElementById(). If imgObj is my image object, I change imgObj.src to
the image URL and I'm checking imgObj.complete to see if it has been
loaded. The problem is that when I change an imgObj that previously
held an image, complete will be true immediately after imgObj.src has
been changed, regardless of whether it is loaded. Is there any way to
avoid this or is there a way to destroy the old image object before I
assign the new src URL?

Don't use the .complete, use .onload of the IMG object. And then look at
the group FAQ with regards to cacheing. You can add the current time, in
milliseconds, to the file name and it will be retrieved from the server.

imgOjb.src = "someFile.png?" + new Date().getTime();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top