Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Get Screen resolution of User in PHP (http://www.go4expert.com/forums/screen-resolution-user-php-t7979/)

coderzone 23Dec2007 19:27

Get Screen resolution of User in PHP
Is there any way to know the User Screen Resolution in PHP.

I am not sure if it can be done also,

onlyani 23Dec2007 21:32

Re: Get Screen resolution of User in PHP
The pages you make (as php developer) could
use client-side javascript to detect the local
screen resolution. Then, theoretically, you could
send an Ajax message back to the server, to set
a session variable, so all subsequent requests
could be either dynamically generated, with differing
image sizes, or you could, maybe, use url-rewriting
to redirect to the right static html (with differing
image sizes).

But that's got a hidden catch22. Because the 37% of
all users who still use 800x600 resolution probably won't
have browsers that can deal with Ajax requests.

Has anybody ever figured out how to optimize image
sizes for different screen resolutions?

shabbir 23Dec2007 22:32

Re: Get Screen resolution of User in PHP
The best possible solution is

<script language="javascript">
if (window.location.search == "") {
window.location.href = window.location + "?width=" + screen.width + "&height=" + screen.height;

Then create a file called screen.php and use this:

$width = $_get['width'];
$height = $_get['height'];

echo "You are using a $width x $height screen resolution";
// And set them into cookies as well.

You can also look into http://www.webmasterworld.com/forum88/4700.htm

All times are GMT +5.5. The time now is 03:59.