J
jubes
Hi,
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
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