Internet Explorer 9, 10 & 11 Event constructor doesn't work

后端 未结 7 796

I am creating an event, so use the DOM Event constructor:

new Event(\'change\');

This works fine in modern browsers, however in Internet Ex

7条回答
  •  死守一世寂寞
    2020-11-28 21:57

    This package does the magic:

    https://www.npmjs.com/package/custom-event-polyfill

    Include the package and dispatch the event as following:

    window.dispatchEvent(new window.CustomEvent('some-event'))
    

提交回复
热议问题