Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-10-2008, 01:14 AM #1
- Join Date
- Aug 2004
- Thanked 0 Times in 0 Posts
Trying to use preloaded images in img src
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.
09-10-2008, 02:43 AM #2
- Join Date
- Jun 2007
- Thanked 591 Times in 572 Posts
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.