IE Javascript Error : Object doesn’t support this property or method

February 18th, 2011 by Nikhil

Had this strange issue , where a piece of Javascript worked fine in all the browser  and as usual sans IE 🙂 …  Simple it was, but since the script was not written by me, It took a while to debug this “Object doesn’t support this property or method” error, that only IE was throwing up. Probably! If  I were to write the script, I wouldn’t have got this error at all , as I tend not to mix my variable names with field Ids :).

Problem: Object doesn’t support this property or method (on line 3)


function funzoneSP(){
    document.getElementById('video_id').style.visibility="hidden";
    shortdesc = document.getElementById('shortdesc').value;
    ....
}

Solution:
The error is generated on the thirdrow in the example above(Line 3… “shortdesc = document.getE….”). I tried all sort of stupid things , that I dont is even worth the mention here and finally guess what!  just changing the shortdesc var to something else got rid of the error. Basically! The variable name had to different from the fieldID

Tags:


get ExpressingIT News by Email Subscribe to ExpressingIT by Email |  Follow Me on Twitter


One Response to “IE Javascript Error : Object doesn’t support this property or method”

  1. Ben Roberts Says:

    This was a great tip on a very bizarre issue which I also observed in IE8/IE9. Firefox, Chrome, Safari and nearly every other browser under the sun worked as expected.

    .
    .
    .
    // Resulted in “Object doesn’t support this property or method” sometimes
    frm_req = $(‘frm_req’);
    .
    .
    .

    .
    .
    .
    // Fixed the issue by using a variable name different from the element ID value
    frm_req_1 = $(‘frm_req’);
    .
    .
    .

    My test/use case:
    Prototype 1.7.0.0
    IE8


Leave a Reply

 Subscribe to ExpressingIT RSS
get ExpressingIT News by Email Subscribe to ExpressingIT by Email
 Follow Me on Twitter