Title: mvc3 google api Microsoft JScript runtime error: 'console' is undefined
Tags: jquery;asp.net-mvc-3;google-maps
Question: 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/
Comment: 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

Here is the accepted answer: 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.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:01/23/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<jquery><asp.net-mvc-3><google-maps>', 'Title': "mvc3 google api Microsoft JScript runtime error: 'console' is undefined", 'ViewCount': 1406, 'id': 14471397, 'user_AboutMe': None, 'user_AccountId': 1739989.0, 'user_DisplayName': 'user1591668', 'user_Reputation': 2263.0, 'user_Views': 372.0, 'user_id': 1591668.0}}