Hello,
here's a function that I have a question about:
function enterPressed(e) {
var charCode;
if (window.event) {
charCode = event.keyCode;
}
else {
charCode = e.which;
}
// alert(charCode);
if (charCode == 13) {
return true;
}
else {
return false;
}
}
Here's the question: in FF, if I say "if (event)", FF says that "event" is not defined. But "if (window.event)" works no problem. Why is that? I know that one of the ways to test whether a variable is set is to use typeof but I think the author of the Rhino book uses "if (window.event)".
here's a function that I have a question about:
function enterPressed(e) {
var charCode;
if (window.event) {
charCode = event.keyCode;
}
else {
charCode = e.which;
}
// alert(charCode);
if (charCode == 13) {
return true;
}
else {
return false;
}
}
Here's the question: in FF, if I say "if (event)", FF says that "event" is not defined. But "if (window.event)" works no problem. Why is that? I know that one of the ways to test whether a variable is set is to use typeof but I think the author of the Rhino book uses "if (window.event)".