How can I make it so that each time when user changes the screen resolution size [not the browser window], the page perform a function?
Answer: Use the window. screen Object You can simply use the width and height property of the window. screen object to get the resolution of the screen (i.e. width and height of the screen).
Ok, so you're using jQuery. So let's make a custom event for it.
(function () { var width = screen.width, height = screen.height; setInterval(function () { if (screen.width !== width || screen.height !== height) { width = screen.width; height = screen.height; $(window).trigger('resolutionchange'); } }, 50); }());
Now $(window).bind('resolutionchange', fn)
should do what you want.
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