javascript call a privileged method
<p>If I call the killSwitch() outside the onkeypress, I'll cause an error.
But inside the onkeypress function, I worked just fine.
Why?</p>

<p><code></p>

<pre><code>// this works fine
var ClassA = function()  
{  
    var doc = document;
// killSwitch();

    doc.onkeypress = function(e){ killSwitch(); }  
    this.killSwitch = function(){ alert('hello world'); }  
}

var myClass = new ClassA();
</code></pre>

<p></code></p>
