...

View Full Version : Trying to use preloaded images in img src



skylab
09-10-2008, 02:14 AM
I'm loading a bunch of html into a span, and from there, in the onload, I'm using JS to reformat the html and repopulate the span's innerhtml. The issue I'm having is with the images. I can set the img src to the image on the server, but it loads each image over and over again, and they are the same image. I've tried using some JS for preloading the image, but again, that doesn't seem to work. It thinks the reference to the preloaded image is the source.

Is there a way to reference the initial source of an image to a preloaded image? The page and html are already loaded. When I'm rewriting the innerHTML with JS, is there a way to set the src of the image so it uses a preloaded image instead of hitting the server over and over again for 100s of times just to get the same image??

I've been beating my head on this for quite awhile and not getting anywhere. Any help or ideas are greatly appreciated. Thank you.

rnd me
09-10-2008, 03:43 AM
it should cache the pic the first time, so the image data is not retransmitted. if you don't care about IE6 and IE7 support, you can read the image into a dataurl and store it as a string. you tehn set the source to that string, and the image displays. heck, you can even use globalStorage to save that string to the user's hard drive to guarantee that your server is not bother again.

Both concepts are coming to IE8, and already present in the other guys.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum