Internet Explorer Undefined Error
Contents |
be down. Please try the request again. Your cache administrator is webmaster. Generated Wed, 19 Oct 2016 04:48:43 GMT by s_wx1011 (squid/3.5.20)
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 'console' is undefined error for http://answers.microsoft.com/en-us/ie/forum/ie10-windows_8/webpage-error-undefined/399062e1-4d3c-4f61-b64c-045d4740a060 Internet Explorer up vote 338 down vote favorite 124 I'm using Firebug and have some statements like: console.log("..."); in my page. In IE8 (probably earlier versions too) I get script errors saying 'console' is undefined. I tried putting this at the top of my page: still I get the errors. Any way to get rid of http://stackoverflow.com/questions/3326650/console-is-undefined-error-for-internet-explorer the errors? javascript internet-explorer internet-explorer-8 firebug share|improve this question edited Oct 31 '13 at 9:11 informatik01 9,30763759 asked Jul 24 '10 at 19:55 user246114 13.4k3383136 4 Use typeof in your if, it will avoid undefined errors: if(typeof console === "undefined") { var console = { log: function (logMsg) { } }; } –Flak DiNenno Feb 4 '13 at 23:19 14 console.log() only works when IE's dev tool is open (yes IE is crappy). see stackoverflow.com/questions/7742781/… –Adrien Be Jul 16 '13 at 13:14 1 Best answer to that question is stackoverflow.com/a/16916941/2274855 –Vinícius Moraes Nov 19 '13 at 15:05 1 see github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js –Aprillion Nov 27 '13 at 15:54 1 @Aprillion link is broken, use this one instead: github.com/h5bp/html5-boilerplate/blob/master/src/js/plugins.js –Alfred Bez Oct 22 '15 at 7:27 | show 2 more comments 21 Answers 21 active oldest votes up vote 349 down vote accepted Try if (!window.console) console = ... An undefined variable cannot be referred directly. However, all global variables are attributes of the same name of the global context (window in case of browsers), and accessing an undefined attribute is fine. Or use if (typeof console === 'undefined') console = ... if
that make connections all over the world. Join today Download & Extend Drupal https://www.drupal.org/node/2123327 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 internet explorer 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 internet explorer undefined 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 proble