How to trigger the window resize event in JavaScript?

Seems to work with Chrome, FF, Safari, but not: IE !

 window.dispatchEvent(new Event('resize'));

That didnt work on all devices for me. I had to trigger the event like this:

var evt = document.createEvent('UIEvents');
evt.initUIEvent('resize', true, false, window, 0);




Developer, Technology aficionado, Beer Lover and founder of Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed