Console overview - Microsoft Edge Developer documentation (2024)

  • Article

The Console is like an intelligent, rich command line within DevTools, and is great companion tool to use with others tools. The Console provides a powerful way to script functionality, inspect the current webpage, and manipulate the current webpage using JavaScript.

The Console tool helps with several tasks, which are covered in more detail in the following articles:

  • Track down problems to find out why something isn't working in the current project. See Fix JavaScript errors that are reported in the Console.
  • Get information about the web project in the browser as log messages. See Filter Console messages.
  • Log information in scripts for debugging purposes. See Log messages in the Console tool.
  • Try JavaScript expressions live in a REPL environment. See Run JavaScript in the Console.
  • Interact with the web project in the browser using JavaScript. See Interact with the DOM using the Console.

You can open the Console tool in the top or bottom of DevTools; it's shown here in upper part, on the Activity Bar:

Console overview - Microsoft Edge Developer documentation (1)

The Console is shown here in the lower part of DevTools (the Quick View panel), with the Elements tool open above it:

Console overview - Microsoft Edge Developer documentation (2)

The fastest way to directly open the Console is to press Ctrl+Shift+J (Windows, Linux) or Command+Option+J (macOS).

Error reports and the Console

The Console is the default place where JavaScript and connectivity errors are reported. For more information, see Fixing JavaScript errors that are reported in the Console.

DevTools gives detailed information about the error in the Console:

Console overview - Microsoft Edge Developer documentation (3)

Search the web for a Console error message string

Search the web for your Console error messages, right from within DevTools. In the Console, many error messages have a Search for this message on the Web button, shown as a magnifying glass:

Console overview - Microsoft Edge Developer documentation (4)

When you click the Search for this message on the Web button, a new tab opens in the browser and shows search results for the error message:

Console overview - Microsoft Edge Developer documentation (5)

Inspect and filter information on the current webpage

When you open DevTools on a webpage, there may be an overwhelming amount of information in the Console. The amount of information becomes a problem when you need to identify important information. To view the important information that needs action, use the Issues tool in DevTools.

Issues are gradually being moved from the Console to the Issues tool. However, there's still a lot of information in the Console, which is why it's a good idea to know about the automated log and filter options in the Console. For more information, see Filter Console messages.

DevTools with a Console full of messages:

Console overview - Microsoft Edge Developer documentation (6)

Log information to display in the Console

The most popular use case for the Console is logging information from your scripts using the console.log() method or other similar methods.

Example code

// prints the text to the console as a log messageconsole.log('This is a log message');// prints the text to the console as an informational messageconsole.info('This is some information'); // prints the text to the console as an error messageconsole.error('This is an error');// prints the text to the console as a warningconsole.warn('This is a warning');// prints the geometry of the document body as an objectconsole.log(document.body.getBoundingClientRect());// prints the geometry of the document body as a tableconsole.table(document.body.getBoundingClientRect());// shows a list of techologies as a collapsed grouplet technologies = ["HTML", "CSS", "SVG", "ECMAScript"];console.groupCollapsed('Technolgies');technologies.forEach(tech => {console.info(tech);})console.groupEnd('Technolgies');

To log information to display in the Console:

  1. Open the demo webpage Console messages examples: log, info, error and warn in a new window or tab.

  2. To open the Console, press Ctrl+Shift+J (Windows, Linux) or Command+Option+J (macOS).

    The Console displays the resulting messages that are caused by the demo code:

    Console overview - Microsoft Edge Developer documentation (7)

  3. Paste the above code into the Console, and then press Enter.

    If you get a message: Uncaught SyntaxError: Identifier 'technologies' has already been declared:

  4. Open a new tab or window.

  5. To open the Console, press Ctrl+Shift+J (Windows, Linux) or Command+Option+J (macOS).

  6. Paste the above code into the Console, and then press Enter.

Many useful methods are available when you work with the Console. For more information, see Log messages in the Console tool.

Try your JavaScript live in the Console

The Console isn't only a place to log information. The Console is a REPL environment. When you write any JavaScript in the Console, the code runs immediately. You may find it useful to test some new JavaScript features or to do some quick calculations. Also, you get all of the features you expect from a modern editing environment, such as autocompletion, syntax highlighting, and history.

To try running JavaScript in the Console:

  1. Open the Console.

  2. Type 2+2.

The Console displays the result of 2+2 live as you type it, displaying the result 4 on the following line:

Console overview - Microsoft Edge Developer documentation (8)

This Eager evaluation feature is useful to debug and verify that you aren't making mistakes in your code.

To run the JavaScript expression in the Console and optionally display a result, press Enter. Then, you can write the next JavaScript code to run in the Console.

Running several lines of JavaScript code in succession:

Console overview - Microsoft Edge Developer documentation (9)

By default, you run JavaScript code on a single line. To run a line, type your JavaScript and then press Enter. To work around the single-line limitation, press Shift+Enter instead of Enter.

Similar to other command-line experiences, to access your previous JavaScript commands, press Up Arrow. The autocompletion feature of the Console is a great way to learn about unfamiliar methods.

To try autocompletion:

  1. Open the Console.
  2. Type doc.
  3. Select document from the dropdown menu.
  4. Press Tab to select document.
  5. Type .bo.
  6. Press Tab to select document.body.
  7. Type another . to display the complete list of properties and methods available on the body of the current webpage.

For more information about all the ways to work with Console, see Console as a JavaScript environment.

Autocompletion of JavaScript expressions in the Console:

Console overview - Microsoft Edge Developer documentation (10)

Interact with the current webpage in the browser

The Console has access to the Window object of the browser. You can write scripts that interact with the current webpage, by reading data from the DOM and assigning data to DOM elements.

Reading from the DOM tree in the Console

To use a JavaScript expression to read from the current page by reading a selected element from the DOM tree:

  1. Open the Console.

  2. Paste the following code into the Console, and then press Enter:

    document.querySelector('h1').innerHTML

    This expression selects the first heading-level 1 from the DOM and then selects the HTML content that's contained between the <h1> start and end tags. The Console displays the output of the expression, which is the text of the heading:

    Console overview - Microsoft Edge Developer documentation (11)

You have read from the DOM representation of the webpage, by entering a JavaScript expression in the Console and displaying the output in the Console.

Writing to the DOM tree and webpage from the Console

You can also change the rendered webpage, by changing the DOM (or writing to the DOM), from within the Console.

To change the rendered webpage:

  1. Open the Console.

  2. Paste the following code into the Console, and then press Enter:

    document.querySelector('h1').innerHTML = 'Rocking the Console';

    The above JavaScript expression uses the = sign to assign a value to the selected DOM item. The evaluated value of the expression is a string for a heading, in this example. The expression's value (the heading string) is shown both in the Console and in the rendered webpage:

    Console overview - Microsoft Edge Developer documentation (12)

    You changed the main heading of the webpage to Rocking the Console.

Using the $$ Console utility method to

The Console Utility methods make it easy to access and manipulate the current webpage.

For example, to add a green border around all the links in the current webpage:

  1. Open the Console.

  2. Paste the following code into the Console, and then press Enter:

    $$('a').forEach(a => a.style.border='1px solid lime');

    The $$(selector) console utility function is "Query selector all". This DOM query selector function returns an array of all the elements that match the specified CSS selector, like the JavaScript function document.querySelectorAll(). In this example, we select all the <a> hyperlink elements and then apply a green box around them:

    Console overview - Microsoft Edge Developer documentation (13)

For more information, see Console tool utility functions and selectors.

See also

  • Interact with the DOM using the Console.
  • Console features reference
  • Console object API Reference
  • Console tool utility functions and selectors
Console overview - Microsoft Edge Developer documentation (2024)

FAQs

How to clear console DevTools? ›

To clear the Console, use any of the following approaches:
  1. Click the Clear console ( ) button.
  2. Right-click a message and then select Clear console.
  3. Type clear() in the Console tool and then press Enter.
  4. Call console.clear() from your webpage's JavaScript.
  5. Press Ctrl+L while the Console tool is in focus.
Mar 22, 2024

How to get console logs from Edge? ›

Microsoft Edge for Console logs

The Developer Tools panel opens. From the Developer panel, click on the Console tab. Click on the gear icon on the top right sidebar. Next, click on the Preserve log checkbox.

What is the overview of Microsoft Edge? ›

Microsoft Edge is your AI-powered browser that helps you achieve more. With unique features like Copilot, Designer, Vertical tabs, Coupons, Read Aloud, and VPN, Edge helps you save time, save money and protect your online privacy.

How do I open the developer console in Edge? ›

To open the developer console in Microsoft Edge, open the Edge Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools. You can also press CTRL + Shift + i to open it. The console will either open up within your existing Edge window, or in a new window.

How do you clear the console in Edge? ›

Clear console

You can also use the shortcut key “Ctrl+L” to clear the console.

How do I clear all console commands? ›

Type cls as a new command, and press Enter. This clears the entire screen. Another way to erase the CMD screen is to reopen the program. Or, you can enter Start to launch a new instance.

How to see hidden console logs? ›

The method to get a console log on Mac and Windows is the same:
  1. In your Chrome browser, click and then More tools > Developer tools. ...
  2. To the upper right of the Developer tools menu, click the settings icon .
  3. Under the Console section, click the following check boxes: ...
  4. To close the page, click at the upper right corner.

How do I extract console logs? ›

Steps to Download Console Logs
  1. Step 1: Open the Developer Console. The first step is to open the developer console in your browser. ...
  2. Step 2: Navigate to the Console Tab. ...
  3. Step 3: Reproduce the Issue. ...
  4. Step 4: Export Console Logs. ...
  5. Step 5: Save the File.
Dec 26, 2023

How do I extract history from Edge? ›

After the Edge browsing history is loaded, you can select one or more items, and then export the history to csv/tab-delimited/html/xml file by using the 'Save Selected Items' option (Ctrl+S). You can also copy the history items to the clipboard (CTRL+C) and then paste them into Excel of other spreadsheet application.

Is Microsoft Edge being discontinued? ›

Support for the legacy version of the Microsoft Edge desktop app ended on March 9, 2021. The Microsoft Edge Legacy application will no longer receive security updates after that date.

What are the disadvantages of Microsoft Edge? ›

1. The main disadvantage is that Microsoft Edge is also a bit slower than other browsers. 2. Edge browser also has been shown to have issues opening large, complex websites, causing errors, or delaying the site for minutes before it opens.

Who owns the Edge browser? ›

Microsoft Edge (or simply Edge) is a proprietary cross-platform web browser created by Microsoft. Released in 2015 as part of Windows 10 and Xbox One, it was initially built with Microsoft's own proprietary browser engine, EdgeHTML, and their Chakra JavaScript engine.

How to view console log in Edge? ›

The method to get a console log on Mac and Windows is the same: In your Edge browser, click and then More tools > Developer tools. Note: It is normal to see that tracing is already running in the Console upon opening. To the upper right of the Developer tools menu, click the settings icon .

How to use the developer console? ›

The simplest is to just right-click somewhere on the page and then select “Inspect Element” in the context menu that appears. You can also launch the developer console using a keyboard shortcut. The shortcut for most browsers on Mac is Command + Option + I, for Windows you can use Ctrl + Shift + I.

How do I give developer console access? ›

Here are the steps to add a user to your project on the Google Developers Console:
  1. Sign in to the Google Developers Console.
  2. Select a project.
  3. On the left menu, select Permissions.
  4. Near the top of your screen, select Add Member.
  5. Type the email address of the user you added to Play Console.
  6. Choose a permission level.

How to clear Devtool cache? ›

In Chrome, or Edge, open DevTools ( F12 ). This step is not needed for Polypane. Right-click on the page refresh icon, in the browser toolbar. Click Empty cache and hard refresh.

How do I clear network dev tools? ›

Open Network Diagnostics. (Customize and control Google Chrome icon), then select More tools, and then Developer tools. Click Network. (Clear) to remove any existing network information in the log.

How do you clear the terminal console? ›

If your terminal gets filled with output and becomes cluttered, you can use the clear command or press Ctrl + L to clear the screen and declutter the terminal quickly. This is particularly useful when working with the Linux command line.

How do you clear the console in visual code? ›

You can set your own keyboard shortcut for it by clicking the settings cog on the right. Now Ctrl+L (or whatever you set as the shortcut) will clear the active terminal (including the Julia REPL).

Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 6664

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.