views:

3480

answers:

10

Php can detect IP, hostname, client agent etc. Can php detect client browser monitor size/resolution?

+2  A: 

You would have to pass that up to a PHP script from JavaScript like most tracking code does (with a transparent image request).

Lloyd
A: 

You'll have to use PHP together with JavaScript, like in this example.

schnaader
+9  A: 

No, it cant. PHP runs on the server, so it cant detect client settings unless you take specific client-side steps to pass the info to the PHP scripts on the server.

Visage
A: 

Monitor size can't be obtained using JS, you have to make a poll :)

Thinker
Ugh? Yes it can.
Lloyd
Lloyd: you can detect the screen resolution, but not the monitor size. A 1600x1200 resolution can mean an old 21" CRT, a moderately big LCD, and a really beautifull and dense smaller screen around 16"
Csaba Kétszeri
+1 because *size* can't be read as per Csaba
ck
+3  A: 

Please do note that some of us like our browsers non-maximized. Perhaps you'd be better off trying to detect browser size rather than screen resolution. I assume that the JS to do either would be very similar, but I don't actually know that to be the case.

Also, what is the resolution of a blind man's screen reader?

Dave Sherohman
+1. I have 2560x1600 screen resolution, I almost never run maximised. You should be reading the view port size (window area not counting toolbars, scrollbars, status bar and window decorations).
SpliFF
+2  A: 

If you have to detect this it simply means your web application is broken.
Don't do it.

Piotr Dobrogost
-1, because HiGuy makes a very valid point
Jeriko
A: 

Note, that JS can check the window size of browser, but this size includes user toolbars, scrollbars etc... Real workspase area in browser depends on those toolbars size.

Jet
+5  A: 

Several of you suggest that there is something wrong with trying to obtain a user's resolution. One in particular suggests that if you have to do this, then your application is broken.

There are so many unique circumstances and situations, that no one can possibly make this claim.

Don't be so eager to jump on someone who is doing something that YOU don't agree with.

A: 

Some people require browser size for mobile devoloping. This is essential information in some cases.

Using WURFL and WALL can get around this as most mobiles do not support JS.

Paul