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,300
  • 7
  • 29
  • 42

1 Answers1

11

The following should work:

var resizeEvent = new Event('resize');

window.dispatchEvent(resizeEvent);

Simple (ridiculously so) demo.

References:

David Thomas
  • 249,100
  • 51
  • 377
  • 410