[thelist] [Javascript] unobtrusive scripting, rollovers and IE7, oh my!

Matt Warden mwarden at gmail.com
Tue Jul 18 20:03:29 CDT 2006

Hash: SHA1

Paul Bennett wrote:
> I'm using Scott Andrew's attachEvent code, which is working fine.
> It's my home-grown rollover code that is throwing the error.

You're half right.

If you switched out the attachEvent function with YUI's event code, your
code would work fine. http://developer.yahoo.com/yui/event/

> Opera and FF both process the rollover code without error, but IE6 and 7 give me this error:
> 'this.src is null or not an object'

In the IE event model, events are fired in the window context. Thus,
'this' refers to the window object. YUI's event utility corrects for
this so that there are no browser differences, but the code you are
using does not.

If you stay with Scott's code, I believe you will be forced to handle
the browser differences on the handler side, then. You can see an
example of that here:


The parameter e will be defined in most browsers, except for IE. In IE,
you must access the window.event object. Then we can retrieve the object
initiating the event by this line:

var source = e.srcElement || e.target;

Then the source variable refers to what you believe the 'this' variable
refers to.

- --
Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the thelist mailing list