Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In IE11, How to use console.log?

Try to use console.log() But it's always printting undefined.

Try to use the solutions like Console.log IE9 issue it does not work as well.

In this IE11 document, there is the following sentence: Last but not least, forget about console.log(). The new tools now support Tracepoints easily allowing you to monitor specific values the same way you would via console.log().

What does that mean? How to use console.log to print variable in IE11?


System: windows 7(VirtualBox IE images)

IE version:11


It seems console.dir() is an option, but how about console.log()? It is in the document, but why does not take effect?

like image 945
Kamel Avatar asked Mar 11 '14 02:03

Kamel


People also ask

How do I open the console in IE11?

You can do this with the keyboard using the F12 key or by selecting “F12 Developer Tools” in the “Tools” menu. The Developer Tools will now be open inside the browser tab, and the DOM Explorer tab will be active. Change to the Console tab by clicking its name.

How do I access the console log?

Steps to Open the Console Log in Google Chrome With the Chrome browser open, right-click anywhere in the browser window and select Inspect from the pop-up menu. By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements".


2 Answers

Even though it's an old question, yet still giving me headache recently when working with IE11.

Simple reason: console object is not initiated unless devtools (i.e. pressing F12 in IE11) is opened.

So a workaround could be, open devtools before loading console.log().

In my case, console.log is loaded when my page is ready, so I open devtools and refresh the page to view my log.

like image 130
Jacky Avatar answered Sep 18 '22 06:09

Jacky


I recently ran into issues with console.log while running the most recent preview build of Windows 10. Below is the code I was trying to log. The log would say my objects functions, proto, and users were undefined. I could "work around" this by changing my version of IE to 9 or putting a breakpoint on console.log(). As far as I can tell, they have just made the console methods more strict to conform with this documentation.

The rules I follow now is to always use console.dir() when outputting objects/variables.

  var PM = PM || {
    users:[]
  };

  var User = (function($){
    //Private Static Variables

    //Constructor
    function User(obj){
      this.id = obj.id;
      this.first = obj.first;
      this.last = obj.last;
    };

    return User;
  })(jQuery); 

  var John = new User({
    id: 1,
    first: 'John',
    last: 'Hargis'
  });
  var Nicole = new User({
    id: 2,
    first: 'Nicole',
    last: 'Hargis'
  });

  PM.users = {
    1: John,
    2: Nicole
  };
  window.console.log(PM); //Undefined
  window.console.dir(PM); //Works    
like image 44
Neve12ende12 Avatar answered Sep 20 '22 06:09

Neve12ende12