|
|
 |
|
|
Pages: 1
detecting resolution javascript to php
(Click here to view the original thread with full colors/images)
Posted by: lcousins
To remove any confusion right at the start, I'm kind of answering a question that hasnt been asked. Im only writing this at all because its one i've known a lot of people ask over the years in other places, and until today I never knew a satisfactory answer.
the question: how do I detect what screen resolution a user is using and then make my php page act on this information.
the answer: php cant detect a users resolution. javascript can. the problem is getting the javascript to output a variable based on this information that php can read.
Previous solutions have included creating a cookie and using javascript to make and execute a form containing the variables, both of which work but are rather tedious and not really for a beginner.
the easiest method is so obvious ,most techies including myself miss it, and that is taking your javascript (there are many to download that detect resolution) and in the redirect section redirect to the same page for all resolutions only add variables at the end eg.
PHP Code:
javascript:
if (Res == '640 + "x" + 480')
location.href="http://www.mypage.com/index.php?res=640";
if (Res == '800 + "x" + 600')
location.href="http://www.mypage.com/index.php?res=800";
if (Res == '1024 + "x" + 720')
location.href="http://www.mypage.com/index.php?res=1024";
and then in index.php you have the '$res' variable to play with....
well, out of the few of you that dont think im mad, hope it helps someone as much as its helped me
m.
Posted by: DemonBob
hmmmm
thanks
/me goes off and plays with this code to see if he can make it better or worse
|
|
|
|
|