...

View Full Version : call event handler



mehere8
06-16-2010, 05:17 PM
if it is done like this:

anElement.onclick=handleIt;

function handleIt()
{ this. ... //'this' refer to the anElement
}
However, if you attach an event, quirk happens:

anElement.attachEvent("onclick",handleIt);
// not sure if anElement.addEventListener("click",handleIt,false) works well
function handleIt()
{ this. ... //'this' refer to an empty object ???????
}

why 'this' doesn't refer to the current target?
anyone can help?

mehere8
06-17-2010, 03:27 PM
er anyone can help?

hdewantara
06-17-2010, 09:53 PM
element.attachEvent() for IE compatibility, right?
"this" for event handlers in IE browser means window, not the element.

mehere8
06-22-2010, 03:34 PM
oh forgot that point ...

thx



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum