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!
This question is related to
javascript
function
internet-explorer-9
undefined
runtime-error
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:
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.
Source: Stackoverflow.com