3

Hi I'm using DOM2 and added a few event listeners "resize" for window object, using addEventListener. And now I need to simulate this action (window.resize) to call event listeners that are attached to the window object. How can I do it?

Simcha
  • 3,170
  • 7
  • 26
  • 40

1 Answers1

11

The following should work:

var resizeEvent = new Event('resize');

window.dispatchEvent(resizeEvent);

Simple (ridiculously so) demo.

References:

David Thomas
  • 240,457
  • 50
  • 366
  • 401