I'm pretty sure that this is caused by you trying to call the log
function on the global object (implicitly), instead of the console
object. You could try something like:

   var log = function(s) { window.console.log(s); }

Cheers,
Kasper

On Wed, Apr 8, 2009 at 11:31 PM, dabear <[email protected]> wrote:
>
> Hi people. Long story short: I'm writing a greasemonkey , opera and
> chrome userscript, wanting to log different things to console. There's
> different ways in the browsers, console.log for fx and chrome, while
> opera uses window.opera.postError (and others). I therefore tried
> doing this to get a variable containing the logging functionality for
> all the mentioned browsers:
>
> var log = (window.console.log || window.opera.postError);
>
> That code raises the following confusing error:
> TypeError: Illegal invocation
>
>
> Realizing that the code above failed, and also would fail in opera (as
> there's no console object), I am now using another approach with a
> series of conditional tests to define a function calling the correct
> logging function. However, as I and someone discussed in #chromium ,
> shouldn't code be allowed to assign a variable to native functions?
>
> Try this in the inspector:
> var log = window.console.log;
> log("foo");
>
> and you will get an this error:
>
> TypeError: Illegal invocation
>
>
> Is this supposed to happen? Is bringing the log function out of scope,
> creating this issue? It indeed works in firebug with firefox, though.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to