Image Cache re-posted

J

jubes

Hi,

Sorry about this, I posted this message yesterday and it ended up in
an existing thread. Hope this time it starts a new one.

I've been developing an intranet application that uses IE 5.5 and have
come across a problem, well sort of.

Since the application uses frames I use an array of Image objects to
cache the image in the top frame. Now replacing an exsiting the image
source on an existing image tag is easy (ie imgTag.src =
imgArry.src) and there is no HTTP request back to the server.

Now expanding that concept further if I create an image tag with
javascript by using divTag.innerHTML = '<img src="imgURL">' this
created tag will make an HTTP request to the server, and since I've
all ready cached all images the server returns a 304 (not modified)
and does not return image data.

So to avoid the HTTP request I tried divTag.innerHTML = '<img src=""
onerror="func(this)" imgIndex="1">'

where

function func(ref){
ref.src =imgArry[ref.imgIndex].src];
}

therefore in this case we have an existing image tag, albeit it throws
an error, and do the normal image replace. now in this scenerio it
still makes a HTTP request.

Why does the last scenario make a HTTP request? Also is there a way to
create an image tag on the fly without it making a HTTP request?

thanks
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top