Microsoft JScript runtime error: Object doesn’t support this property or method.

Yesterday I spent two hours analyzing this issue, which of course I had only with Internet Explorer…

As the background: I wrote a library that would make a table sortable and paginable. I decided to use prototype.js and script.aculo.us. I tried to test the result not only in Firefox which I use by default, but then I simply forgot… Then, when I run the page I got the error:

Microsoft JScript runtime error: Object doesn’t support this property or method.

At the end of the day, (after cutting JavaScript files into slices) I found the reason. All because I created HTML elements like follows (this example uses Builder of script.aculo.us):

$(this._sPaginationSecId).appendChild(Builder.node('span', { class: 'disabled' }, '<'));

If you look at that closer, you will find out that class is not put inside apostrophes (‘). Changing the above snippet to the one below will solve the case:

$(this._sPaginationSecId).appendChild(Builder.node('span', { 'class': 'disabled' }, '<'));

Important!
Be careful with defining properties like href and class with Builder.node() (of script.aculo.us) and new Element() (of prototype).


It’s also possible to define class name of a DOM object created with prototype.js or script.aculo.us using className as a parameter (instead of od 'class'):

$(this._sPaginationSecId).appendChild(Builder.node('span', { className: 'disabled' }, '<'));
 Microsoft JScript runtime error: Object doesnt support this property or method.

22 Responses to “Microsoft JScript runtime error: Object doesn’t support this property or method.”


  • I have written an out-proc COM server.
    And I have an .htm file (which is there in project since quite a while now) which has the java script in it.

    I have declared this com server in the .htm file like this..

    where, VFPlugin is my com server.

    When I try to call the exported methods in the java script, I get this error saying Microsoft JScript error: Object doesn’t support this property or method”. Could you please explain me why is this?

  • Basavaraj,
    For some reason, your code won’t appear in the comment… I’m not sure why…
    Please try again. If it doesn’t appear, probably JS code is not allowed in my WordPress engine or settings I’ve applied…

    Jarek

  • I’m setting up a password and i have .js file i tried to run it but it said Microsoft JScript run time error

  • Hi, I am also getting the same erro, tried everything but not working.
    can anybody plz help on this.
    Here is my script.

    /* Your web page must contain this:
    * Loading …
    */
    window.onload = setupFunc;

    function setupFunc() {
    document.getElementsByTagName(‘body’)[0].onclick = clickFunc;
    hideBusysign();
    Wicket.Ajax.registerPreCallHandler(showBusysign);
    Wicket.Ajax.registerPostCallHandler(hideBusysign);
    Wicket.Ajax.registerFailureHandler(hideBusysign);
    }

    function hideBusysign() {

    document.getElementById(‘busysign’).style.display =’none’;
    }

    function showBusysign() {

    document.getElementById(‘busysign’).style.display =’inline’;

    }

    function clickFunc(eventData) {

    var clickedElement = (window.event) ? event.srcElement : eventData.target;

    if(clickedElement.type == null) {
    clickedElement.type = “Nothing”
    }
    if (document.getElementById(‘busysign’).style.display == ‘none’ &&
    (clickedElement.tagName.toUpperCase() ==’SPAN’
    ||clickedElement.type.toUpperCase() ==’RADIO’) ) {

    showBusysign();
    }
    }

    function autoRefresh(){

    document.autorefresh.submit();

    }

  • Ashish,

    Can you provide sth more than only JS code? It itself looks ok (can’t see weak points)…

    I created an AJAX enabled Web Project, added your JS snippet and a div with id=”busysign” and some text inside. Wehen I ran the page, I got JS error: Wicket is not defined or sth like that.

    Ta,
    Jarek

  • Hi Jarek,

    Here is actual culprit. When I run this script, I am getting the above error. Using the below script I am trying to open four popups and using child funtcion refresh the same on any selection.

    <!–*/

    var testwindow1= ” “;
    var testwindow2= ” “;
    var testwindow3= ” “;
    var testwindow4= ” “;

    function callDataView()
    {
    //only refresh
    if(testwindow1 != null) {
    testwindow1.callChildFun();
    }
    if(testwindow2 != null) {
    testwindow2.callChildFun();
    }
    if(testwindow3 != null) {
    testwindow3.callChildFun();
    }
    if(testwindow4 != null) {
    testwindow4.callChildFun();
    }
    }

    function callDataView_open()
    {
    if(testwindow1 != null) {
    testwindow1 =window.open(“../XYLineChartExample.html?selectReport=reportone” , “dataViewOne”, “menubar=1,resizable=1,width=350,height=250″);
    testwindow1.moveTo(0,0);
    }

    if(testwindow2 != null) {
    testwindow2 =window.open(“../XYLineChartExample.html?selectReport=reporttwo” , “dataViewTwo”, “menubar=1,resizable=1,width=350,height=250″);
    testwindow2.moveTo(0,450);
    }

    if(testwindow3 != null) {
    testwindow3 =window.open(“../XYLineChartExample.html?selectReport=reportthree” , “dataViewThree”, “menubar=1,resizable=1,width=350,height=250″);
    testwindow3.moveTo(450,0);
    }

    if(testwindow4 != null) {
    testwindow4 =window.open(“../XYLineChartExample.html?selectReport=reportfour” , “dataViewFour”, “menubar=1,resizable=1,width=350,height=250″);
    testwindow4.moveTo(450,450);
    }
    }

    It will be great if you suggest something.

    Thanks,
    Ashish

  • Could you send me the full example (HTML, JavaScript, etc.) so I can look at the stuff as it is? My email: jaroslaw AT dobrzanski DELETE_THIS DOT net (use ‘at’ and ‘dot’ characters and delete what should be deleted) :)

    Jarek

  • Hi Jarek,

    The thing is, I am using the wicket in this html, if I send u the html, it will just give u wicket error not js as above.
    Is there anything u can help with this or way?

    Ashish

  • Sorry, I can’t find the reason for your problems…

  • hi, i cant understand anything here… somehow i was just trying to run a game, Dance Battle Audition but it says this error:

    An error has occurred in the script on this page:
    Line: 12
    Char: 2
    Error: Object doesnt support this property or method
    Code: 0
    URL: https://www.e-games.com.ph/asp/login/t3login_pVK.asp
    Do you want to continue running scripts on this page?
    Yes / No

    Can you teach me simple instructions on how to fix it? Im not really good with all the terms. I have a Windows Vista and Internet Explorer 10. Thanks!

  • Problems like this are easy to detect if you use JSLint. (http://jslint.com/)

  • Its because IE can’t handle json packets without explicit strings as keys. The mind boggles how that browser reached such status.

    http://www.harelmalka.com/?p=104

  • I’m fairly certain there’s a tidbit of doc that covers this…
    You’re supposed to use either ‘class’ or className, but not class.

    I couldn’t find an explanitory doc about it, but this references it…
    http://www.prototypejs.org/api/element/addclassname

  • Iona, you have IE 10? that’s pretty new!

    You can rig up the Microsoft Scripting for applications to break into the jscript engine and it will give you the line and even a stack trace. Install the scripting host, enable script debug in explorer and ‘web debugging’ in an office app and the options should appear.

    try out: support.microsoft.com/kb/822521

  • You are getting the error because class is a reserved word in Microsoft’s JScript engine http://msdn.microsoft.com/en-us/library/ttyab5c8.aspx. You cannot use reserved words other wise it will throw exceptions like the one you got above.

  • Just wasting some time on Stumbleupon and I found your entry. Not typically what I prefer to learn about, but it was absolutely worth my time. Thanks.

  • In my case i had an issue with this bug. After post back my page used to get messed up.. After tracing down i came to know that the culprit was “SmartNavigation”. I disabled it and it worked all fine!!!

  • tell me if i can stop showing these type of error. i found that

    “my code run three or four function [some of them because not implement in browser or not supported ]”

    so when i am trying to run the page or refresh i got same error every time. these is not good that they harsh me everytime by showing a error who really not error.

    code is work fine everyhwhere. well tell me if their is option to stop these type of error showing in VS.

  • You suggest fixing a bug by replacing this:

    $(this._sPaginationSecId).appendChild(Builder.node(‘span’, { class: ‘disabled’ }, ‘<'));

    with this:

    $(this._sPaginationSecId).appendChild(Builder.node('span', { 'class': 'disabled' }, '<'));

    But, according to my JavaScript book (JavaScript: The Definitive Guide), object literal syntax requires the key to NOT be in quotes. That would mean that the first above is correct and the second is incorrect. Am I missing something?

  • John,

    That might be true. That’s why I’m also mentioning in the post that it’s possible to use className. Example with className is provided in the post, more details: http://madrobby.github.com/scriptaculous/builder/

    Cheers,
    Jarek

  • Hi Jarosław,
    I was getting this same error, only in IE an could not resolve it until I found the solution here. Thanks a lot. Although it is weird that IE does not recognize the json identifiers by name whereas FireFox works fine i.e.

    cache: isCacheAllowed, height: 5,//works in FF, Opera only

    ‘cache’: isCacheAllowed, ‘height’: 5,//works in all browsers

  • Hi there,
    I have a same problem could you please help me
    int k = 0;
    for (k = 0; k <= RadGrid1.Items.Count – 1; k++)
    {

    dynamic Txt1 = (Telerik.Web.UI.RadTextBox)RadGrid1.Items[k].FindControl("RadTextBox2");

    if (Txt1.Text == e.SourceDragNode.Text)
    {
    Txt1.Text = "";
    }
    }

    string fileStr = null;
    fileStr = e.SourceDragNode.Text + "," + e.SourceDragNode.Attributes["FileURL"];
    string script = "function f(){$(\"#" + e.HtmlElementID + "\").val('" + e.SourceDragNode.Text + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);

Leave a Reply