Search code examples
javascriptconsoleinternet-explorer-9ie-developer-tools

show line numbers for console statements in IE 9 debugger


I hope this is something simple.. I am using the F12 Development tool debugger in IE 9. Is there a way I can display the line numbers and file source for each console statement, the same way that Firebug displays this info? I may have overlooked something basic, but I haven't yet found a way to do this..Thanks!


Solution

  • The only way to get line numbers is to define a window.onerror method:

    window.onerror = function (message, url, lineNo)
      {
      console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);
    
      return true;
      }
    
    console.log(window);
    console.log(1=2);
    

    But even then, IE breaks on the error, so it's rather useless.