# Identify user's screen resolution???



## DrP (Jul 23, 2005)

Can I identify a users screen resolution using PHP?
I'm thinking of using a different stylesheet depending upon the screen resolution.
I'd also be interested in any comments people have on doing this and whether it is a waste of time or not.
Any help will be mucho appreciated,


----------



## Rockn (Jul 29, 2001)

PHP is a server side language. You would need something client side like Java to determine the screen resolution.


----------



## brendandonhu (Jul 8, 2002)

You can get it in JavaScript (for most users) and pass it to your PHP script.


----------



## DrP (Jul 23, 2005)

Does that mean it isn't sent to the server like, for example, the IP address is?


----------



## brendandonhu (Jul 8, 2002)

Right


----------



## DrP (Jul 23, 2005)

Ok. Thanks, I've found a script I can use:
http://javascript.internet.com/user-details/bg-based-on-screen-resolution.html
and
http://www.htmlgoodies.com/beyond/javascript/article.php/3471261
though I am not sue whether it is worth bothering as some people don't always maximise their browser anyway.


----------



## thecoalman (Mar 6, 2006)

DrP said:


> though I am not sue whether it is worth bothering as some people don't always maximise their browser anyway.


That's why I build all my sites fluid. It's maxed no matter what resolution they are using.


----------



## treydx (Jan 4, 2006)

Instead of googling for "screen resolution" try searching for "viewport width". You really shouldn't care what their resolution is.

I think (off the top of my head) it's something like 
document.documentElement.clientWidth
document.body.clientWidth
and I think there are a few others like innerWidth, it's pretty inconsistent between browsers.

Check www.themaninblue.com, one of his experiments has to do with creating a certain number of columns based on the viewport width. It's very, very informative (and cool).


----------

