i know that you with $(window).width() can get the size of the web browser.
i want to detect when the user change the size of his web browser so i could readjust the columns width. is there a way to automatically detect this or do i have to use setTimeinterval to loop and see if it has changed?
You can not control the size of the window. You can use CSS to set min-width and min-height properties to ensure your page layout stays sane. using 'window. open' I can open a page with a fixed height width.
You can use . resize() to get every time the width/height actually changes, like this: $(window). resize(function() { //resize just happened, pixels changed });
* Press Alt+Space to bring up the window menu, press S to choose the Size option, use the arrow keys to resize the window, and lastly Enter to confirm. * Click the Maximize button in the top right corner of the window.
Use window. innerWidth and window. innerHeight to get the current screen size of a page.
Try the resize event
$(window).resize(function() { console.log('window was resized'); });
Writing this down cause somehow none of these answers give the modern best-practices way of doing this:
window.addEventListener("resize", function(event) { console.log(document.body.clientWidth + ' wide by ' + document.body.clientHeight+' high'); })
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