Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Image Object complete not accurate?

Reply
Thread Tools

Image Object complete not accurate?

 
 
Rob T
Guest
Posts: n/a
 
      11-02-2006
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
 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      11-02-2006
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();

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
New Releases: Mr. & Mrs. Smith, Complete Buffy & Enterprise: Updated complete R1 DVD DB & info lists Doug MacLean DVD Video 0 08-09-2005 05:07 AM
Re: Request: A+ Complete 3rd edition (PDF) [1/1] - A+ Complete 3rd edition.txt (1/1) Spammy Sammy A+ Certification 0 03-04-2005 12:55 PM
New Releases: Criterion additions, WB Gangsters & Coupling: Complete: Updated complete downloadable R1 DVD DB& info lists Doug MacLean DVD Video 4 11-07-2004 05:20 PM
Mr. Bean Complete Bean NOT complete!! Waterperson77 DVD Video 5 12-10-2003 05:22 PM



Advertisments