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?
Asked
Active
Viewed 6,718 times
3

Simcha
- 3,300
- 7
- 29
- 42
1 Answers
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