We have a site developed in PHP. It is working just fine. We have used JQuery for every kind of situation like slide shows, menus, etc.
This site contains a lot of images which are large in size. because of this when viewed in a mobile phone user has to scroll a lot.
How can we recognize whether the cl开发者_Go百科ient (browser) trying to access our site is a mobile phone or a standard PC.
Is there any standard way to build site for such situations?
TIA
You should look at Tera-WURFL, it is a PHP & MySQL-based software package that detects mobile devices and their capabilities. Here is the Tera-WURFL code that you would use to detect if a request is coming from a mobile device:
<?php
require_once("TeraWurfl.php");
$wurflObj = new TeraWurfl();
$wurflObj->GetDeviceCapabilitiesFromAgent();
if($wurflObj->capabilities['product_info']['is_wireless_device']){
echo "This is a mobile device";
}else{
echo "This is a desktop browser";
}
?>
you should check the user-agent header which is sent along the HTTP request. Since there are so many useragents, it's really difficult to recognize the various devices/platforms. For this purpose there is a freeware library which can help out : wurfl
Basically it maps the user-agent to a device object which you can query for it's capabilities. This way in your layout you can take advantage of the device's screenwidth/height, what image formats it supports, etc
http://beradrian.wordpress.com/2008/10/10/mobile-device-recognition/
We sometimes use Apache rewrite rules when a client wants to divert traffic before it reaches our server.
See http://www.bemoko.com//training.team/help/team/pc-to-mobile-redirect for more information.
精彩评论