Detecting user's screen size and resolution
If you're developing a site, you should carefully consider how your web pages appear on different kinds of screens. Today people access website on devices with different types of screens, you should account for some factors that affect the way your web pages appear on these devices. Javascript one simple way is to identify the screen width with the help of javascript and then render the webpage accordingly. Following is sample code to identify screen width and set it in cookie. <?php if(isset($_COOKIE["device_resolution"])) $screen_res = $_COOKIE["device_resolution"]; else //cookie is not found set it using Javascript { ?> <? } echo "Your screen resolution is set at ". $screen_res; ?> PHP With php, it is very easy to identify device using $_SERVER['HTTP_USER_AGENT']. Usining strpos() function find position of first occurrence of a string. <?php $iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPho...
Comments
Post a Comment