Menu
Hello all.
Im writing a class for context menues in web pages. I have problem with accessing properties of my class from event function. To understand my question i will paste a test code.
[script]
function myClass() {
this.a = ‘test1’;
this.b = ‘test2’;
this.MDown = function () {
alert(this.a); // I need to access variable a from myClass. But this return error because “this” in this case refers to the HTML element the event is handled by
}
document.addEventListener(‘mousedown’, this.MDown, false);
}
var a = new myClass();
[/script]