Script error in IE is very frustrating as it comes frequently and with some error and it doesn't get closed and pops up again and again. I got the same error while using the google map and unable to pan the map, either zoom in or zoom out. Got the error like: (see screen shot).
While exploring the issue i got that the issue was coming from onion.js file which is a javascript library file. This file gets included automatically when you use Google Map API file (https://maps.googleapis.com/maps/api/js/v=3&sensor=false).
I got the exact problem why we usually get the script error in onion.js. Onion.js is a javascript file and there is a java script function called JSON.pasre() used in that particular file and some of IE browsers(Ex- IE7) don't support the JSON.parse method and it shows a script error.
To reproduce this issue you have to check/uncheck some of the functionalities in Internet option.
- Open IE, goto settings and click on Internet Options.
- Goto Advanced tab and see Browsing.
- Uncheck 'Disable script debugging(Internet Explorer)'.
- Uncheck 'Disable script debugging (Other)'.
- Check 'Display a notification about every script error.'
Inorder to resolve the issue i added below java script code in the same page where the Google map API is being called and it worked.
<script type="text/javascript">
window.onerror = function() {
return true;
};
</script>
Defining the onerror event with a function that returns a value of true at the very top of your page suppresses all scripting errors on the page .
Important Notes:
Be careful while using this event, since it only suppresses errors, but doesn't fix them. Whenever you test codes in your browser, make sure to first turn off the error suppressor.
While exploring the issue i got that the issue was coming from onion.js file which is a javascript library file. This file gets included automatically when you use Google Map API file (https://maps.googleapis.com/maps/api/js/v=3&sensor=false).
I got the exact problem why we usually get the script error in onion.js. Onion.js is a javascript file and there is a java script function called JSON.pasre() used in that particular file and some of IE browsers(Ex- IE7) don't support the JSON.parse method and it shows a script error.
To reproduce this issue you have to check/uncheck some of the functionalities in Internet option.
- Open IE, goto settings and click on Internet Options.
- Goto Advanced tab and see Browsing.
- Uncheck 'Disable script debugging(Internet Explorer)'.
- Uncheck 'Disable script debugging (Other)'.
- Check 'Display a notification about every script error.'
Inorder to resolve the issue i added below java script code in the same page where the Google map API is being called and it worked.
<script type="text/javascript">
window.onerror = function() {
return true;
};
</script>
Defining the onerror event with a function that returns a value of true at the very top of your page suppresses all scripting errors on the page .
Important Notes:
Be careful while using this event, since it only suppresses errors, but doesn't fix them. Whenever you test codes in your browser, make sure to first turn off the error suppressor.