1

So I am working on a project where I have a massive array that corresponds to the colors in a picture that the user can click on in order to select a color. I have the array in a seperate .js file and after that file loads I have an onload handler begin the rest of my script. It works in Chrome / FF but in IE it does not work unless I open the debugger. If I open the debugger it reloads the page and the array works fine. I don't have any ideas. Here is the link to my page which has the project on it its the top post on the page currently: http://sauron.hostoi.com/log/

joel
  • 109
  • 1
  • 1
  • 5

1 Answers1

4

It works in Chrome / FF but in IE it does not work unless I open the debugger. If I open the debugger it reloads the page and the array works fine.

You're using console.log().

When you open the Developer Tools, the console object is defined. Until you do that, there is no console object in Internet Explorer: Does IE9 support console.log, and is it a real function?

To fix the problem, you can either remove/comment out the console.log() calls, or add something like this at the start of your JavaScript:

// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

(snippet taken from http://html5boilerplate.com/)

Community
  • 1
  • 1
thirtydot
  • 224,678
  • 48
  • 389
  • 349