I am assigning the javaEnabled() function to a variable like this:
var je = navigator.javaEnabled;
Now when I try to invoke the function using je();
, it throws an error in chrome that says
VM960:1 Uncaught TypeError: Illegal invocation(…)
In Firefox, the error is:
TypeError: 'javaEnabled' called on an object that does not implement interface Navigator.
Why does it fail like this?
If you call something like
obj.func()
,func
will be called withobj
as itsthis
value. Firefox complains about an incompatiblethis
value. In your case it's eithernull
or the global object (normallywindow
), depending on context and if youuse strict
.javaEnabled
needs thenavigator
object, just esObject.valueOf()
needsObject
.