You are here: Reference > JavaScript > core > objects > Debug

Debug object

Browser support:
With the Debug object, you can send messages to the output window of the opened script debugger in Internet Explorer.
  • The Debug object cannot be instantiated.
  • The members of the Debug object are static, they can only be accessed through the Debug object (Debug.member).
  • The Debug object is available anywhere within the JavaScript code.
To use the Debug object, script debugging mode need to be enabled in your browser (Tools / Internet Options / Advanced / Browsing section). When script debugging is enabled and a script error occurs, then the browser suggests the use of one of the installed script debugger applications.
Note: the script debugging applications can also be opened with the debugger statement directly.

The Debug object supports the write and writeln methods to send messages to the output window of the opened script debugger.

To send messages to a console in Firefox, use the reportError method for the Error Console and the dump method for the Console window. In Opera, use the postError method for the Error Console.

Syntax:

Sending a message to the output window of the debugger:
Debug.write (message);

Members:

The Debug object inherits from the Object.prototype object. The following list only contains the members of the Debug object.

Methods:

Method Support Description
write ([message1 [, message2 [, ... [, messageN]]]])
Sends messages to the script debugger.
message Optional. Strings to send to the script debugger.
writeln ([message1 [, message2 [, ... [, messageN]]]])
Sends messages to the script debugger, followed by a newline character.
message Optional. Strings to send to the script debugger.

Examples:

Sending message to the console:
debugger;   // open a script debugger application
    // step over the following lines with the script debugger, 
    // you will see the result in the output window of the debugger application
Debug.write ("first message");
Debug.writeln ("second message in the same line");
Debug.writeln ("third message in the next line");
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content