javascript call a privileged method
- by quan
If I call the killSwitch() outside the onkeypress, I'll cause an error.
But inside the onkeypress function, I worked just fine.
Why?
// 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();