Joshua Olson wrote:
>Simon,
>>Thank you for you complete example. I owe you an apology because it looks
>like I wasn't 100% succinct. Clearly, in your example, the cookie that is
>set by the image is available on subsequent page loads. I can honestly say
>that I was sure that would work. What I was looking to do was to read the
>cookie AFTER the image loaded in the page, but without a page refresh. To
>test, I fired a function to check for cookies within the image's onload
>handler.
>>>In my live test example I *do* have access to the cookie using
*JavaScript* on initial page load but only after the page has completed
loading. My onload event is on the body tag. It was PHP that required
the refresh.
>Something like this:
>><img src="whatever.php" onload="checkforcookies()" />
>><script>
> function checkforcookies()
> {
> alert(document.cookie);
> }
></script>
>>I don't think that an image tag supports the onload event :-(
http://www.w3.org/TR/REC-html40/struct/objects.htmlhttp://www.w3.org/TR/REC-html40/sgml/dtd.html#events
Move the onload event trigger to the <body> element and I bet it works.
>In case you are wondering, my goal is to pass some meta information (about
>1k worth) about the picture back to the browser for parsing and subsequent
>display. The picture may be dynamically changed using javascript. I was
>hoping to avoid spinning off a second call to the server to retrieve this
>information.
>>Still not clear what you are trying to achieve or quite what you mean by
"meta information" in this context?
Simon