In order to design an exact web interface, I need to get client's monitor resolution with javascript whenever they access my web. Is this possible?
-
Thank you. What's about browser's dimension? Could you help me with this? – Lewis Mar 20 '14 at 09:18
-
It is in the same question mentioned above if you read all answers and comments carefully. With JQuery it's `$(window).height()` & `$(window).width()`. For plain JS write your own like `wndsize()` here http://stackoverflow.com/a/9237810/643500 – Sully Mar 20 '14 at 09:23
2 Answers
For a plain vanilla answer to your question, simply look at screen.height or screen.width.
e.g.
window.screen.height
window.screen.width
For browser dimensions, you can simply use window.height
or window.width
If you're looking at altering design/layout based on available space, you want to look at media queries or using a framework like Bootstrap, Foundation or Skel.js which introduce more accessible control over responsiveness.
Media Queries is a CSS3 module allowing content rendering to adapt to conditions such as screen resolution (e.g. smartphone vs. high definition screen). It became a W3C recommended standard in June 2012. and is a cornerstone technology of Responsive Web Design.
[...]
Responsive Web Design (RWD) is a Web design approach aimed at crafting sites to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from mobile phones to desktop computer monitors)

- 69,876
- 20
- 132
- 137
Here is a code :
document.write("Available Width: " + screen.availWidth);
document.write("Available Height: " + screen.availHeight);
Source : http://www.w3schools.com/js/js_window_screen.asp
Cannot comment but here is solution for browser height :
window.innerHeight/Width
Provided by most browsers, but not Internet Explorer 8-, and even in Internet Explorer 9+, it is not available in quirks mode.
document.body.clientHeight/Width
Provided by many browsers, including Internet Explorer.
document.documentElement.clientHeight/Width
Provided by most DOM browsers, including Internet Explorer.
Source : http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

- 760
- 8
- 23