[thelist] Cookies and images

Simon Perry thelist at si-designs.co.uk
Fri Feb 4 12:20:16 CST 2005


Joshua Olson wrote:

>>-----Original Message-----
>>
>>I don't think that an image tag supports the onload event :-(
>>
>>http://www.w3.org/TR/REC-html40/struct/objects.html
>>http://www.w3.org/TR/REC-html40/sgml/dtd.html#events
>>    
>>
>
>Holy cow.  I never realized that before, but it looks like you may be
>correct.
>
>  
>
>>Move the onload event trigger to the <body> element and I bet 
>>it works.
>>    
>>
>
>For images referenced directly within the HTML, you are most likely correct.
>However, I plan on loading images dynamically after the page is loaded.
>  
>
The theory should hold strong if you call a new image from your 
generation program from JavaScript. The image generation program will 
still send the same data including setting a new cookie. The only gotcha 
I could think of would be caching the image source so you may need to 
add a bogus unique query string with each call.

<img src="generator.php?unique_hash" />

>Here's an example of what I'm trying to accomplish...
>
>Let's say we have an online photo archive of 1 million photos.  I'd like to
>have a button that replaces the existing image (without a page refresh) by
>updating the image src to call a page on the server to return a single
>random image from the archive.  I'd also like the photographers name, the
>copyright year, the camera information, and the email address of the
>copyright holder to be returned with the image.  My thought was to have the
>information returned as cookies within the image so that I can publish them
>to the page in appropriate places.
>  
>
Well that certainly makes more sense. How about a js routine with an 
array of all your data fields that is populated server side when the 
page is first called. When the first say 20 images are exhausted simply 
change the links to reload the page and a new script will be created 
with fresh images. This way you could also easily cache the images to 
make it very slick.

More random brainstorming;

JavaScript + XML -You can run XML queries without page refreshes
JavaScript + EXIF - Don't even know if you can access EXIF data from 
jpegs using JavaScript?

Simon


More information about the thelist mailing list