Object doesn’t support this property or method javascript error
In some browsers it would throw a “silent” error and stop executing javascript code. If you try to open page in IE in debug mode it would alert error message like this:
Object doesn’t support this property or method
I faced such problem today when i performed a calculation and assigned the calculated value to a variable without initializing the variable. In IE8 and Safari 5.0.2 the page just stopped to respond to javascript calls after a certain point of execution. Here’s what i had been trying to do.
container = Math.round(total/9.5);
after i added var to the variable container to look it like var container = Math.round(total/9.5); it started to work in IE and Safari. Fyi, it worked just fine in Firefox 4.0.1, Opera 11.10 and Chrome 11.0 with variable without var declaration.
Also, i remember (not very much sure but i think it happened) that at a place within the same code i had been trying to divide 0(zero) by a number and it threw a similar Object doesn’t support this property or method error. This is what i had been trying to do:
var total = parseFloat($("#SubTotal").val());
var remainder = (total/9.5) - Math.round(total/9.5);
In case when variable total held 0(zero) it would throw me similar error i.e. Object doesn’t support this property or method in IE and stopped working. Also in Safari it stopped working without showing any error message. Once i added a code line between those two lines, looking like the code below, it started working just fine and stopped showing an error in IE.
var total = parseFloat($("#SubTotal").val());
if(total<=0) return 0;// or something similar
var remainder = (total/9.5) - Math.round(total/9.5);
I do reckon that it happen to me and i had to fix it but right now even if i comment the if(total<=0) return 0; line out it still works fine. Seeking comments from you guys to throw some light on these issues.
Thanks.
Possibly Related posts:
- Random string generation with Javascript
Here is a small but useful function to generate a string with a random number of characters with the help of javascript. function randomString(min, max)... - WordPress custom permalinks and 404 error
Today morning i found that urls to postings of this very blog of mine were ending on a “HTTP 404 – File not found” page.... - Working on ANZ-egate payment method for WP-Commerce
Working on ANZ-egate payment method for WP-E-commerce plugin at the moment and doing final testing. I hope it will be ready to be shared soon.... - Error handling in cakephp
Error handling in CakePHP is pretty simple and straight forward. While developing in CakePHP with debug value set to > 0 (Configure::write(‘debug’, 1); in app/config/core.php)... - Validating php multiple-value checkbox form element with javascript
In php a multiple-value form element such as checkbox is named suffixed with a set of square brackets. For example, My commonly used colors are:...
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.





