Re: howto install event handler



nstasiv@xxxxxxxxx wrote:
<snip>
this.obj.onmousedown = function(evt){
this.pickup(evt);
}
won't work as expected, please help!

In javascript the value of - this - is determined entirely by how a
function is called and has no relationship with how or where code that
uses it is declared/defined. When the browser calls an event handler
assigned to an event handling property of an Element it calls that
handler as a method of the Element, and so - this - is a reference to
the Element.

There are several techniques for associating DOM Element's event
handlers with javascript object instances. Many are based upon
closures:-

<URL: http://jibbering.com/faq/faq_notes/closures.html >

Richard.

.



Relevant Pages