You are here: Reference > JavaScript > client-side > HTML DOM > methods > dump (window)

dump method (window)

Browser support:
Prints the specified message to the console.
The dump method is commonly used to help JavaScript debugging. This method is disabled by default in Firefox. Set the 'browser.dom.window.dump.enabled' to true in the about:config page or in a user.js file to enable it.
Sometimes the console window is not shown. In that case, close all running Firefox applications and open a new one from the command line with the -console parameter.
The Error Console can also be used for message dumping. Use the reportError method or the nsIConsoleService object for that purpose. See the examples for details.
  • In Internet Explorer, use the Debug object to send messages to the output window of an opened script debugger.
  • In Opera, use the postError method to print messages to the Error Console.

Syntax:

object.dump (text);
You can find the related objects in the Supported by objects section below.

Parameters:

text
Required. String that specifies the text to print.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the dump method:
<head>
    <script type="text/javascript">
        if (window.dump) {
            window.dump ("A message for the Console window.");
        }
        else {
            alert ("Your browser does not support the dump method!");
        }
    </script>
</head>
Did you find this example helpful? yes no

Example HTML code 2:

This example prints an error message to the Error Console:
<head>
    <script type="text/javascript">
        if (window.Components) {
                // UniversalXPConnect privilege is required in Firefox
            try {
                if (window.netscape && netscape.security) { // Firefox
                    netscape.security.PrivilegeManager.enablePrivilege ("UniversalXPConnect");
                }
            }
            catch (e) {
                alert ("UniversalXPConnect privilege is required for this operation!");
                return;
            }

            Components.utils.reportError ("An error message for the Error Console.");
        }
        else {
            alert ("Your browser does not support this example!");
        }
    </script>
</head>
Did you find this example helpful? yes no

Example HTML code 3:

This example prints a message to the Error Console:
<head>
    <script type="text/javascript">
        if (window.Components) {
                // UniversalXPConnect privilege is required in Firefox
            try {
                if (window.netscape && netscape.security) { // Firefox
                    netscape.security.PrivilegeManager.enablePrivilege ("UniversalXPConnect");
                }
            }
            catch (e) {
                alert ("UniversalXPConnect privilege is required for this operation!");
                return;
            }

            var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
            console.logStringMessage("A message for the Error Console.");
        }
        else {
            alert ("Your browser does not support this example!");
        }
    </script>
</head>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content