[Javascript] attachEvent and "this"
Matt Warden
mwarden at gmail.com
Fri Aug 12 10:39:02 CDT 2005
On 8/12/05, Julien Nadeau <junado at junado.com> wrote:
> My question is, using unobstrusive event handlers, how can I get to use the
> "this" keyword in Internet Explorer 6 so that I can get the info contained
> in the "dest" attribute. Is there's a way?
function bar(e) {
// if e parameter isn't defined, use IE's 'event' var
e = e || event;
alert("The source element's id is: "+ (e.srcelement || e.target).id)
}
document.getElementById('foo').onclick = bar;
In IE, 'event' is a "global" reference to the current event.
--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
More information about the Javascript
mailing list