Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing windows resize to fire

Tags:

javascript

I have problems with my layout, when I re-size window manually and restore it to normal everything is in the perfect place.

Is it possible to trick the browser and do something with JavaScript that would actually make the browser think that the page has been re-sized so that my layout looks as it should?

UPDATE:

Can I re-size and restore window so that user barely notices?

like image 843
Gandalf StormCrow Avatar asked Dec 07 '09 16:12

Gandalf StormCrow


People also ask

What happens when the window is resized?

The resize event fires when the document view (window) has been resized. This event is not cancelable and does not bubble. In some earlier browsers it was possible to register resize event handlers on any HTML element.


1 Answers

Since then a better solution has been posted in https://stackoverflow.com/a/18693617/2306587:

window.dispatchEvent(new Event('resize')); 
like image 198
BillyTom Avatar answered Oct 05 '22 16:10

BillyTom