This below would be my ideal code.... if it worked.
<html><head><sc ript>
function mouseDownClass( o){
this.o = o;
this.handleMous eUp = function() {
alert(this);
}
//treating this section as the constructor (which sets up the mouseup
listener as the method of an instantiation, ideally)
document.body.a ddEventListener ("mouseup",this .handleMouseUp, false);
}
</script></head><body>
<button id="b1" onmousedown="ne w mouseDownClass( this,event)">Do wn
-> Up</button>
</body></html>
alert() is showing 'this' to as: [object HTMLBodyElement] whereas i'm
looking for it to show [object Object], (On Firefox at least),
referring to the object instantiated when the mouse goes down on the
button. I'd appreciate anyone who can help me here?
Thanks in advance
Jody
<html><head><sc ript>
function mouseDownClass( o){
this.o = o;
this.handleMous eUp = function() {
alert(this);
}
//treating this section as the constructor (which sets up the mouseup
listener as the method of an instantiation, ideally)
document.body.a ddEventListener ("mouseup",this .handleMouseUp, false);
}
</script></head><body>
<button id="b1" onmousedown="ne w mouseDownClass( this,event)">Do wn
-> Up</button>
</body></html>
alert() is showing 'this' to as: [object HTMLBodyElement] whereas i'm
looking for it to show [object Object], (On Firefox at least),
referring to the object instantiated when the mouse goes down on the
button. I'd appreciate anyone who can help me here?
Thanks in advance
Jody
Comment