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

后端 未结 7 759

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 22:11

    the custom-event npm package worked beautifully for me

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

    var CustomEvent = require('custom-event');
    
    // add an appropriate event listener
    target.addEventListener('cat', function(e) { process(e.detail) });
    
    // create and dispatch the event
    var event = new CustomEvent('cat', {
      detail: {
        hazcheeseburger: true
      }
    });
    target.dispatchEvent(event);
    
    0 讨论(0)
提交回复
热议问题