Internet Explorer Error Console.log
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Does IE9 support console.log, and is it a real function? up vote 180 down vote favorite 63 In which circumstances is window.console.log defined in Internet Explorer 9? Even when window.console.log is defined, window.console.log.apply and window.console.log.call are undefined. Why is this? [Related question for IE8: What happened to console.log in IE8?.] javascript logging internet-explorer-9 share|improve this question asked Mar 29 '11 at 13:03 mloughran 5,52462020 3 Check out this great post about the intricacies of IE8-9 console object/function: whattheheadsaid.com/2011/04/… –Marc Climent Dec 30 '11 at 13:37 See also 'console' is undefined error for internet explorer –Bergi Nov 10 '12 at 12:34 add a comment| 7 Answers 7 active oldest votes up vote 261 down vote accepted In Internet Explorer 9 (and 8), the console object is only exposed when the developer tools are opened for a particular tab. If you hide the developer tools window for that tab, the console object remains exposed for each page you navigate to. If you open a new tab, you must also open the developer tools for that tab in order for the console object to be exposed. The console object is not part of any standard and is an extension to the Document Object Model. Like other DOM objects, it is considered a host object and is not required to inherit from Object, nor its methods from Function, like native ECMAScript functions and objects do. This is the reason apply and call are undefined on those methods. In IE 9, most DOM objects were improved to inherit from native ECMAScript types. As the developer tools are considered an extension to IE (albeit, a built-in extension), they clearly didn't receive the same improvements as the rest of the DOM. For what it's worth, you can still use some Function.prototype methods on console methods with a little bind() magic: var log = Function.prototype.bind.call(console.log, console); log.apply(console, ["this", "is", "a", "test"]); //-> "thisisatest" shar
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Internet Explorer 9 Samples and Tutorials Debugging and Troubleshooting Your Webpage How to use F12 Developer Tools to Debug your Webpages How to use F12 Developer Tools to Debug http://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function your Webpages Using the F12 Tools Console to View Errors and Status Using the F12 Tools Console to View Errors and Status Using the F12 Tools Console to View Errors and Status Introduction to F12 Developer Tools Getting Started with the F12 Developer Tools Using the F12 Tools Console to View Errors and Status F12 tools https://msdn.microsoft.com/en-us/library/gg589530(v=vs.85).aspx console error messages Using the F12 Developer Tools to Debug JavaScript Errors Using F12 Developer Tools to Debug HTML and CSS Using the Profiler Tool to analyze the performance of your code TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Using the F12 Tools Console to View Errors and Status This content refers to an older version of F12 developer tools. Please visit our latest F12 tools documentation. The F12 tools console commands let you receive error messages from Windows Internet Explorer 9, as well as send your own messages back from your code without having to break the flow of your execution. You can use the F12 tools console view to immediately run script statements outside your program code. The console tab and view Sending messages from code to console Executing script and commands in the console Using cd() to execute commands across frames Ex
the code will break IE or any Firefox that doesn't have Firebug installed, since console and console.log will be undefined. so i wonder how about disabling it just by if (typeof console == "undefined" || typeof https://www.sitepoint.com/community/t/how-not-to-let-console-log-to-cause-error-on-ie-or-other-browsers/4307 console.log == "undefined") var console = { log: function() {} }; at the very top https://www.drupal.org/node/2123327 of javascript code. It is true we could use if (debugging) console.log(oDiv) but then we need to constant turn debugging on and off on different browsers, and it is more troublesome to use "if (debugging)" every time. This following line will work too: if (typeof console == "undefined") var console = { log: function() {} }; except there might be some internet explorer browser in which console is defined, but console.log is undefined... and using console.log() in those browser will cause an error. So the first solution in this post that test for both console and console.log is a better check. Paul_Wilkins 2008-10-05 19:57:10 UTC #2 That sounds like an interesting idea. I would have thought though that cross-browser testing would have caught anything untoward that remained. I'm also not keen on the idea of having some console.log commands remain internet explorer error in production code that will get seen by visitors who also use firebug. winterheat 2008-10-05 20:02:31 UTC #3 pmw57 said: That sounds like an interesting idea. I would have thought though that cross-browser testing would have caught anything untoward that remained. I'm also not keen on the idea of having some console.log commands remain in production code that will get seen by visitors who also use firebug. yeah, when it is production, we can remove all the console.log() calls... or if we don't care about them remaining in the code, we can use var debugging = false; // or trueif (!debugging || typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function() {} }; hm... but I think Firefox with Firebug doesn't let us redefine console... so maybe there is another way... (just found out that console.log can be reassigned on Firefox with Firebug) something like var debugging = false; // or trueif (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function() {} };else if (!debugging && typeof console != "undefined") console.log = function() {}; you meant to use Browser sniffing to define console.log()? I tried it too and since my Firefox on Mac doesn't have Firebug, it gave error for using console.log() when it is not defined. winterheat 2008-10-05 20:33:14 UTC #4 actually, i thin
that make connections all over the world. Join today Download & Extend Drupal Core Distributions Modules Themes Media ColorboxIssues IE 8 throws "console is undefined" error, breaking all other javascript on the page Needs workProject:Media ColorboxVersion:7.x-1.x-devComponent:CodePriority:CriticalCategory:Bug reportAssigned:UnassignedReporter:dianacastilloCreated:October 29, 2013 - 19:20Updated:April 10, 2015 - 13:34 Log in or register to update this issue Jump to:Most recent comment Most recent attachment this module causes a "'console' is undefined" error in mediacolorbox.js when using IE 8 . Has anyone run across this problem?Files: CommentFileSizeAuthor #2 media_colorbox-fix_console_undefined.patch489 bytescoredumperror Comments Comment #1 coredumperror CreditAttribution: coredumperror commented October 29, 2013 at 10:34pm I'm currently working on tracking this down as well, because it completely breaks my site for users on IE8. It appears to be related to media_colorbox.js being loaded without jquery.colorbox-min.js also being loaded. Log in or register to post comments Comment #2 coredumperror CreditAttribution: coredumperror commented October 29, 2013 at 11:05pm Title: IE 8 causes 'console' is undefined » IE 8 throws "console is undefined" error, breaking all other javascript on the page Version: 7.x-1.0-rc4 » 7.x-1.x-dev Priority: Normal » Critical Status: Active » Needs review FileSize media_colorbox-fix_console_undefined.patch489 bytes OK, here's a patch that fixes this problem. It changes the media_colorbox.js file to only call console.log() if the console object actually exists. The attached patch is just a quick and dirty fix. The real fix for this is to take the "scripts[] = media_colorbox.js" line out of media_colorbox.info, and instead call drupal_add_js() to add the media_colorbox.js file only where it's needed. The problem arises because media_colorbox.js currently gets added to every page, but jquery.colorbox.js doesn't, which is what's triggering the call to console.log(). I'd do this step myself, but I don't know which functions would need to have that drupal_add_js() line. I'm also bumping this issue to critical, because IE8's braindead javascript engine kills all JS execution as soon as it encounters an error. Thus, this problem breaks every other javascript file on the page for IE8 user