Using the console API

The Firebug console API allows javascript programs to write to the console (along with a few other tricks). It is available for use, but is disabled by default. To enable it, use the following code:

var engine = new Jurassic.ScriptEngine();
engine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(engine));

Here's an example of using the console object within JavaScript:

var x = 15, y = 'test';
console.log('X is %i, Y is %s', x, y);
This prints "X is 15, Y is test" to the console.

Only a subset of the functionality of the Firebug console API is available at this time.
The available functions are:
  • log
  • debug
  • info
  • warn
  • error
  • assert
  • group
  • groupEnd
  • time
  • timeEnd

In addition, only the following format string specifiers are supported:
%s string
%d integer
%i integer
%f floating point number



Next tutorial: Calling a single .NET method from JavaScript

Last edited Aug 25, 2010 at 2:51 PM by paulbartrum, version 11

Comments

No comments yet.