sowmithrii Posted December 6, 2007 Share Posted December 6, 2007 can any one tell me or give me some example code how to get the user's (of my website) monitor resolution like 800 x 600 or 1024 X768 ... regards sowmithrii Quote Link to comment https://forums.phpfreaks.com/topic/80423-how-to-get-users-monitor-resolution/ Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 You can do it through javascript using the screen object alert(screen.width); alert(screen.height); you have to pass them to php some how Quote Link to comment https://forums.phpfreaks.com/topic/80423-how-to-get-users-monitor-resolution/#findComment-407762 Share on other sites More sharing options...
PHP_PhREEEk Posted December 6, 2007 Share Posted December 6, 2007 Ever heard of Google? http://www.google.com/search?q=php+monitor+resolution First result: Lifted from daniweb.com <?php $url = $_SERVER['PHP_SELF']; if ( isset($HTTP_COOKIE_VARS["res"]) ) { $res = $HTTP_COOKIE_VARS["res"]; } else { ?> <script language="javascript"> <!-- go(); function go() { var today = new Date(); var the_date = new Date("August 31, 2020"); var the_cookie_date = the_date.toGMTString(); var the_cookie = "res="+ screen.width +"x"+ screen.height; var the_cookie = the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location = '<?echo "$url";?>'; } //--> </script> <?php } ?> <?php //Let's "split" the resolution results into two variables list($width, $height) = split('[x]', $res); //Take the width and height minus 300 $tb_width = $width-300; $tb_height = $height-300; //Make the table print("<table align=center border=1 width=" .$tb_width . " height=" . $ tb_height . " > <tr> <td align=center>Your screen resolution is " . $width . " by " . $height . ".<br>The width/height of this table is " . $tb_width . " by " . $tb_height . ".</td> </tr> </table>"); ?> Not tested... YMMV PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80423-how-to-get-users-monitor-resolution/#findComment-407764 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.