Forum Moderators: coopster

Message Too Old, No Replies

Auto-detecting resolution with php?

...can it be done without Javascript?

         

habitat675

3:09 pm on Mar 30, 2003 (gmt 0)

10+ Year Member



I know you can detect the browser in php, but is there a way to detect the screen resolution? Some preset variables or something? I can't find a way without javascript. If not, what's the best way to do it with javascript? I want it to be something like this:

if screen resolution is something

$variable = "lowres";

else

$variable = "highres";

Not necessarily that simple but you get the idea. Does anyone know how/if I can do this with just php? thanks.

-erin

jatar_k

5:46 pm on Mar 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have never seen it done with php, only javascript.

I don't know if it would be possible given that php is server side it doesnt know anything about the client per se.

Fischerlaender

10:02 pm on Mar 30, 2003 (gmt 0)

10+ Year Member



You cannot do it with PHP, because PHP is processed on the server and just the results of these processings are sent to the client.

One workaround would be to detect the resolution using JS on your startpage and then to redirect according to the resolution:

if(highres) 
window.location.href = "page.php?res=high"
else
window.location.href = "page.php?res=low"

I think you get the idea.