[thelist] bug in Safari using onload on Image objects created thru JS?

Chris Nott cnott at telus.net
Wed Jan 28 22:01:19 CST 2004

If I create an image using new Image, assign it a src property, and attach
an onload event handler (either using the DOM0 method of assigning to the
onload property or using the addEventListener() method), some properties of
the event object in the event handler and the 'this' object don't appear to
be correctly populated in Safari.  event.type is 'load' as it should be but
event.currentTarget and event.target are both undefined but, in Mozilla,
these return a reference to the Image object.  I'm not sure what 'this'
contains in Safari (alerting it gives a blank string) but it should also
contain a reference to the Image object as it does in Mozilla.

I have a demo page at

Is this a bug in Safari and is there any way to get a reference to the Image
object from inside the event handler?

- chris

More information about the thelist mailing list