0

I am using google maps api on my MVC3 website everything works perfect on Firefox but in Internet explorer I get a error message saying Microsoft JScript runtime error: 'console' is undefined . I have tried to fix this the code that is highlighted is console.log("changed: " + $(object).attr('id')); the portion of that code is

  $(document).bind("location_changed", function (event, object) {
    console.log("changed: " + $(object).attr('id'));

});

the Console is only causing problems with Internet Explorer . How can i fix that.. and i got the code from http://www.wimagguc.com/projects/jquery-latitude-longitude-picker-gmaps/

user1591668
  • 2,591
  • 5
  • 41
  • 84
  • 1
    duplicate question. see http://stackoverflow.com/questions/9725111/internet-explorer-console-is-not-defined-error or http://stackoverflow.com/questions/3326650/console-is-undefined-error-for-internet-explorer – mfanto Jan 23 '13 at 02:25

1 Answers1

1

IE8 and lower does not have a console. Some browsers do not have a console, so when using the console in javascript, it's a best practice to see if it exists first:

$(document).bind("location_changed", function (event, object) {
    if (window.console) {
        console.log("changed: " + $(object).attr('id'));
    }
});

You can see this answer for how to turn console.log into alerts when console is not defined.

Community
  • 1
  • 1
Martin
  • 11,031
  • 8
  • 50
  • 77