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

Matt Warden mwarden at gmail.com
Tue Jul 18 20:35:00 CDT 2006

Hash: SHA1

Paul Bennett wrote:
>> If you switched out the attachEvent function with YUI's event code, your
>> code would work fine. http://developer.yahoo.com/yui/event/
> Thanks for the heads up Matt.
> That file alone is 38Kb!! I know that's not a big deal in this age of broadband net access, but I do like to keep things slim & trim...

You are looking at the expanded version, which includes loads and loads
of javadoc-like documentation and proper syntax formatting. YUI includes
minified versions of all their code. For example, the event-min.js is 9kb.

>> 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.
> So couldn't I then use something like this:
> if(this){
> 	imgObject = this;
> }
> else {
> 	imgObject = window.event;
> }
> Or am I way off-track?

No, that will not work. 'this' will always be defined, it's just defined
as different things in different browsers. Also, the logic is still off
as far as what you would assign imgObject to. I would suggest using YUI
for simplicity, but if you don't want to for size concerns then adapt
the code I provide in my sandbox. If you need help specifically
customizing this for your needs, I could lend a hand.

- --
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