11

I want to get live screen resolution of web browser as user RESTORE DOWN OR MAXIMIZE without refreshing the page.

udaya shakya
  • 169
  • 1
  • 2
  • 7

2 Answers2

14

Are you using jQuery? If yes, then the code below should work

$(window).resize(function(){
 var windowWidth = $(window).width();
 var windowHeight = $(window).height();
 // windowWidth & windowHeight are automatically updated when the browser size is modified
});
Karthik Rao
  • 321
  • 3
  • 9
12

Not entirely sure what you're after, but here are some suggestions.

window.screen contains the current OS resolution. That is accessible via screen.height and screen.width. Two other interesting values might be availHeight and availWidth (not 100% sure about the cross-browser availabilty there)

If you need to know the current browser-dimensions, that is stored on the window object itself. window.innerHeight, window.outerHeight, window.innerWidth and window.outerWidth are the values of interest there. The inner prefixed values do reflect the working(client) area of the browser, whereas the outer prefixes contain the whole browser window area.

jAndy
  • 212,463
  • 51
  • 293
  • 348