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?
The following should work:
var resizeEvent = new Event('resize');
window.dispatchEvent(resizeEvent);
Simple (ridiculously so) demo.
References:
Event() constructor.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With