[javascript] IE throws JavaScript Error: The value of the property 'googleMapsQuery' is null or undefined, not a Function object (works in other browsers)

I'm having a real problem with JavaScript scope in IE 9.

This is inside the body of my document (yes, I realize script should go in the head for proper HTML, but I've never had it break a script before). The script is in the body because I don't want to mess with a shared header page for a script that is only relevant for this page:

<script type="text/javascript">
function googleMapsQuery(accountNum) {
    // function code is here (omitted for brevity)
}
</script>

This is inside a td block inside a tr block inside a tbody block inside a table block inside a form block inside the body:

<button id="google-422111" onclick="googleMapsQuery(422111)" type="button">Google This!</button>

I even moved the script block above the form just in case the order of the script function declaration was relevant (it's not).

The script works flawlessly in FireFox and Chrome, but in IE 9 (with or without compatibility view on), I get this error:

SCRIPT5007: The value of the property 'googleMapsQuery' is null or undefined, not a Function object

I studied JavaScript scope, and I cannot figure out any reason why IE thinks that 'googleMapsQuery' is a property, and why it is undefined. It's a function, and I defined it!

The answer is


Have you tried adding the semicolon to onclick="googleMapsQuery(422111);". I don't have enough of your code to test if the missing semicolon would cause the error, but ie is more picky about syntax.


Just a few minutes ago i was facing the same problem. I got the problem that is after just placing your jQuery start the other jQuery scripting. After all it will work fine.


I was having a similar issue with a property being null or undefined.

This ended up being that IE's document mode was being defaulted to IE7 Standards. This was due to the compatibility mode being automatically set to be used for all intranet sites (Tools > Compatibility View Setting > Display Intranet Sites in Compatibility View).


In my particular case, I had a similar error on a legacy website used in my organization. To solve the issue, I had to list the website a a "Trusted site".

To do so:

  • Click the Tools button, and then Internet options.
  • Go on the Security tab.
  • Click on Trusted sites and then on the sites button.
  • Enter the url of the website and click on Add.

I'm leaving this here in the remote case it will help someone.


So I had a similar situation with the same error. I forgot I changed the compatibility mode on my dev machine and I had a console.log command in my javascript as well. I changed compatibility mode back in IE, and removed the console.log command. No more issue.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to function

$http.get(...).success is not a function Function to calculate R2 (R-squared) in R How to Call a Function inside a Render in React/Jsx How does Python return multiple values from a function? Default optional parameter in Swift function How to have multiple conditions for one if statement in python Uncaught TypeError: .indexOf is not a function Proper use of const for defining functions in JavaScript Run php function on button click includes() not working in all browsers

Examples related to internet-explorer-9

How do I fix twitter-bootstrap on IE? Forcing Internet Explorer 9 to use standards document mode IE9 jQuery AJAX with CORS returns "Access is denied" X-Frame-Options Allow-From multiple domains IE throws JavaScript Error: The value of the property 'googleMapsQuery' is null or undefined, not a Function object (works in other browsers) Why does JavaScript only work after opening developer tools in IE once? HTML5 - mp4 video does not play in IE9 addEventListener in Internet Explorer css3 text-shadow in IE9 Placeholder in IE9

Examples related to undefined

Checking for Undefined In React Raw_Input() Is Not Defined How to resolve TypeError: Cannot convert undefined or null to object "undefined" function declared in another file? Passing Variable through JavaScript from one html page to another page Javascript - removing undefined fields from an object PHP How to fix Notice: Undefined variable: Undefined Symbols for architecture x86_64: Compiling problems Undefined or null for AngularJS PHP Notice: Undefined offset: 1 with array when reading data

Examples related to runtime-error

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined' what does Error "Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" mean? javac: invalid target release: 1.8 C++ error : terminate called after throwing an instance of 'std::bad_alloc' Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Error No Main class found in NetBeans Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 TypeError: Cannot read property "0" from undefined Array Index Out of Bounds Exception (Java) Excel VBA Automation Error: The object invoked has disconnected from its clients