none
Microsoft JScript runtime error: Unable to get value of the property 'attachEvent': object is null or undefined

    Question

  • I am trying to convert C# program VS2008 to  VS2010 -   I am on IE9 - I am getting this error ==>Microsoft JScript runtime error: Unable to get value of the property 'attachEvent': object is null or undefined  ==>

    function

    SetUpForm() {

    varfrm = document.frmMain;

    frm.attachEvent(

    "onkeyup", doEnterPress);

    frm.attachEvent(

    "onkeydown", doEnterPress);

    frm.tbLogin.focus();

    }

    Thank You


    • Edited by JoandCourt Saturday, May 05, 2012 4:17 PM
    Saturday, May 05, 2012 4:07 PM

All replies

  • I am trying to convert C# program VS2008 to  VS2010 -   I am on IE9- I am getting this error ==>Microsoft JScript runtime error: Unable to get value of the property 'attachEvent': object is null or undefined  ==>

    function

    SetUpForm() {

    varfrm = document.frmMain;

    frm.attachEvent(

    "onkeyup", doEnterPress);

    frm.attachEvent(

    "onkeydown", doEnterPress);

    frm.tbLogin.focus();

    }

    Thank You


    • Edited by JoandCourt Saturday, May 05, 2012 4:29 PM
    • Merged by Alexander Sun Wednesday, May 09, 2012 10:00 AM Duplicate
    Saturday, May 05, 2012 4:29 PM
  • it is not easy to get the root cause at a glance of your discription. you can try to use the Firebug or IE develop Tools to find out which line causes your issue. Hope it helps.



    Monday, May 21, 2012 5:48 AM
  • Usually I put this way to make it works on "cross-browser"

    //detect which event listener to use for which browser

    if(window.addEventListener) {
     document.write("This browse supports addEventListener");
    } else if(window.attachEvent) {
     document.write("This browse supports attachEvent");
    }

    I believe IE9 will use addEventListener.

    Friday, June 08, 2012 3:41 AM