# JS: Detect User's Resolution, >1 Screens?



## TIGR (Jul 18, 2011)

I'm using JavaScript's screen.width and screen.height to detect the screen resolution of a web page's users. This works fine regardless of the number of monitors a user has, except in IE and Opera.

*IE* seems to return the current screen resolution of whichever display is set in Windows as the primary display.

*Opera* seems to return the resolution of whichever display it was originally opened in, when it was opened—_even if the resolution of that display has since been changed_. Cheater.

I already have separate code in place to detect the height and width of the browser window/frame. Can anyone help me get the actual screen resolution of the screen the browser is currently in? Thanks. 

FYI I have only tested in Chrome 12, Firefox 5, IE 8 and 9, Opera 11.5, and Safari 5.0.5 so far. The demographics of this web site's users also demand compatibility with Chrome 10 and 11, Firefox 3.6 and 4, IE 6 and 7, Opera 10.5 and 11.5, and Safari 3.2 and 4.


----------



## W1zzard (Jul 18, 2011)

design your html in a way that it works without knowing the resolution

what are you trying to do anyway?


----------



## TIGR (Jul 18, 2011)

W1zzard said:


> design your html in a way that it works without knowing the resolution
> 
> what are you trying to do anyway?



The question isn't about page design, it is "Can anyone help me get the actual screen resolution of the screen the browser is currently in?" Page design is already optimized for a wide array of resolutions and is enhanced aesthetically and functionally for users whose specific browser/frame res can be reliably detected as mentioned in the OP.

Respectfully, again I'm just looking for the answer to the question "Can anyone help me get the actual screen resolution of the screen the browser is currently in?"


----------



## W1zzard (Jul 18, 2011)

you could use css 3 media selectors ?

good info on the whole viewport ecosystem:
http://www.quirksmode.org/mobile/tableViewport.html


----------



## GSG-9 (Jul 31, 2011)

What W1zzard said is probably your best bet, your other option would be to use analytic software like piwik to find the monitor resolution, and cross reference if they are using dual monitors. I attached an image of the piwik interface to give you an idea of what I mean.

Although this is not a real time solution, it will only tell you the resolution (I believe) of the monitor the window was on at page load.​



Hope thats of some use! http://piwik.org/


----------



## TIGR (Aug 1, 2011)

Thanks GSG-9, looking into it.


----------

