How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To deal with “Object doesn’t support this property or method” issue in JavaScript, while using events and Internet Explorer, update your code with this −


      <meta http-equiv="X-UA-Compatible" content="IE=edge;" />

You can also use attachEvent in IE to solve this issue like this −

if (ev.addEventListener) {
   ev.addEventListener('click', myText, false);
else if (ev.attachEvent) {
    ev.attachEvent('onclick', myText);
Updated on 23-Jun-2020 13:05:00