Javascript seting dom event to prototype method in constructor
<p>I'm having some Javascript woes, lets say we have a constructor</p>

<pre><code>function test(element) {
  this.element = element;
  this.element.onfocus = function() { this.onfocus(); }
}

test.prototype.onfocus = function() {
  alert("focused");
}

new test(document.getElementByID("E1"));
</code></pre>

<p>So I am trying to dynamically set the focus event inside the constructor, but it doesn't seem to work, and I can't figure it out. </p>

<p>Anyone help?</p>

<p>Thanks,</p>

<p>AJ</p>
