[thelist] Cookies and images

Matt Warden mwarden at gmail.com
Fri Feb 4 16:40:43 CST 2005


On Fri, 4 Feb 2005 13:57:49 -0500, Joshua Olson <joshua at waetech.com> wrote:
> I'm halfway surprised that the w3 spec didn't account for adding ways to add
> meta-information to binary information (downloads, images, sounds, etc) as
> they were sent to the browser.  While it is possible to send meta
> information via cookies, it doesn't seem to be available in the calling
> document in all cases (at least not in IE, which is still, believe it or
> not, the most prolific browser available).

Have you tried something like this:

img.src = "/foo/bar.jpg";
setTimeout("alert(document.cookie);", 5000);

to test whether the cookie is added to document.cookie after the image
is loaded? I know you said that the img.onload seems to work in
IE/Moz, but if it's non-spec, I guess I would check and make sure it's
not just half-implemented.

> Wait a sec... I just had a ridiculous thought... what if, on the server, I
> packaged the jpeg into a JS variable, assigned the meta data to js
> variables, and then returned the information using the RPC technique posted
> the other day by Keith Gaughan.  Is there a way to "draw" an image from JS
> data if it's encoded the right way?


<img src="javascript:imagedata" width="16" height="16">

where imagedata is a javasript variable that holds the image data.

Whether this is a good idea is left as an exercise for the reader.

However, it does look like it would solve your problem if you did a
XMLHttpRequest() for something like:

        <author>Joe Blow</author>

You might have to do some fancy character-to-binary conversion with
the contents of <data></data>, because it will probably be interpreted
as text.

AFAIK, though, IE doesn't like any image format in this form but XBM.

Matt Warden
Miami University
Oxford, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list