>> KYSCORP.COM TUTORIALS >> PHP Tutorials

User's Screen resolution detection



Overview

This script allows the detection of the visitor screen resolution.
There's no PHP function that can detect the screen resolution, so the trick is to use a javascript code that reloads the page and that will capture the width and the height of the screen.



Script to be put on the top of the page
<?
if(empty($res))
{
echo '<script language="JavaScript">
<!-- debut
document.location="page.php3?res=1&w="+screen.width+"&h="+screen.height;
// end -->
</script>';
}
else
{
echo "Screen Resolution : ".$w."*".$h;
}
?>
Easy ain't it ? Carpe diem...