0

I've been running my Sharepoint web page for a long time with no problems (well, not this problem), and today I got:

Message: 'console' is undefined
Line: 1124

Note: this problem was occuring in IE, but not in Chrome. In IE, Browser Mode is IE 8; Document Mode is IE 8 Standards (Page Default)

Line 1124 is the "console.log()" line below:

$(document).ready(function () {
    console.log('The ready function has been reached'); 
});

I found the solution to this here.

windowskm's comment below kennytm's answer says, "place if (!window.console) console = {log: function() {}}; at the top of your page!"

I did that, and the error went away. But I would like to know why and how that problem popped up "out of the murky grey sky" (it's raining here in Santa Cruz as I keyboard this) - it's not just academic curiosity, but I'm wondering if whatever caused that issue might also have had some as-yet undetected deleterious effects elsewhere that I need to look out for.

IOW, one problem is solved using the solution above, but is there something deeper that I need to root out?

Community
  • 1
  • 1
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • What do you mean? As I said, it's worked fine for weeks - why the sudden change? What could cause it? – B. Clay Shannon-B. Crow Raven Aug 06 '15 at 17:06
  • 1
    @Mouser IE8 does have a console. – Oriol Aug 06 '15 at 17:06
  • 1
    Out of curiousity, why are you using IE8 still? – Mouser Aug 06 '15 at 17:07
  • That is simply the browser installed as the default on the Dev server; I much prefer Chrome, but many of our users are still on IE 8, and thus I have to test in a "lowest common denominator" mode. – B. Clay Shannon-B. Crow Raven Aug 06 '15 at 17:11
  • 1
    Have you (or your organization) rolled out updates recently? If so, one of those may have changed the default behavior or a setting value that affected the assumptions underlying your site's implementation. One example might be to enable (or disable) intranet application compatibility. When displayed in compat view, Intranet apps default to IE7 standards mode. IE7 did not support a console, thus an error would occur. The change you made prevented the call in such a case; that's why the error went away. Perhaps the next question is what is the current doc mode and why? – Lance Leonard Aug 06 '15 at 17:17
  • As mentioned in the question, Document Mode is IE 8 Standards (Page Default). Why? I don't know - I didn't make it that, or change it. Should it be something different? – B. Clay Shannon-B. Crow Raven Aug 06 '15 at 17:49

1 Answers1

3

IE 8 will always throw that error if there is a call to console.log when the Developer Tools are not open.

Essentially, to IE 8, it is a null reference until the console is open.

Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55