Javascript "this" Losing Context In Ie
The following works fine in firefox/safari/chrome, in IE, 'this' appears to be losing context in the handleEvent() function...the result of the alert is [object Window], which is n
Solution 1:
.attachEvent()
doesn't give you this
as the element. You'd need to wrap the handler in a function that invokes it from the context of the element to which it is attached.
if( this.element.attachEvent ) {
var that = this;
this.element.attachEvent("onclick", function() {
that.handleEvent.call( that.element );
} );
}
Post a Comment for "Javascript "this" Losing Context In Ie"