Possible Duplicates:
'this' keyword, not clear
this operator in javascript
function foo()
{
if(this === window)
return null;
return 1;
}
var i = foo(); // returns 1;
What is the this
member of a global function, and how can I test from within a function if it's being called in a global scope or as a member function?
Edit: It seems JQuery makes a difference here, since everybody assures me foo
should return null
for run-of-the-mill JavaScript. How does JQuery change this?
Note that the OP says, in a comment, below, that this is in a Greasemonkey script.