javainternet-explorer-11servlet-filters

Getting Error "Object doesn't support property or method 'attachEvent'" in IE11 but work in IE8, IE9, IE10


I am working on Java doFilter Popup and open iFrame jQuery popup with URL which called SAP.

My code is working for Chrome, Mozilla firefox, IE8, IE9 and IE10 but I am getting a:

Object doesn't support property or method 'attachEvent'" Error in IE11.

Is there any issue with IE11 ?

Any help is deeply appreciated.

Thanks.


Solution

  • In older versions of IE, attachEvent is used to attach an event handler for some event on some element. But as per the update here, starting with IE11, attachEvent is deprecated and you should use addEventListener instead.

    IE has included support for addEventListener from IE9 and above only. So if you still need to support IE8, I suggest you use some cross-browser library like jQuery to bind event handlers instead of vanilla javascript.

    As you're already using jQuery, you can bind events like below

    $('#yourElement').on('click', function(){
       // do something when you click on yourElement
    });