您可以通过多种方式实现这一点,PHP、纯Javascript、Jquery。。。取决于主题/应用程序中的许多其他变量。我可以列出所有方法的利弊,但这不是正确的地方。。
例如,在php中,您可以直接在用户代理上或通过get\\u browser()使用浏览器检测。
简单示例:
if(strstr($_SERVER[\'HTTP_USER_AGENT\'],\'iPod\') || strstr($_SERVER[\'HTTP_USER_AGENT\'],\'iPhone\'))
{
// LINK TO NORMAL
}else {
//were not - put SWF
}
iOs一起:
$iPod = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPod");
$iPhone = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPhone");
$iPad = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPad");
if( $iPod || $iPhone || $iPad ){
//were an iPhone/iPod touch/iPad -- Load normal link
}else {
//were not - put SWF
}
?>
移动设备的全面检测:
//Detect special conditions devices
$iPod = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPod");
$iPhone = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPhone");
$iPad = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPad");
if(stripos($_SERVER[\'HTTP_USER_AGENT\'],"Android") && stripos($_SERVER[\'HTTP_USER_AGENT\'],"mobile")){
$Android = true;
}else if(stripos($_SERVER[\'HTTP_USER_AGENT\'],"Android")){
$Android = false;
$AndroidTablet = true;
}else{
$Android = false;
$AndroidTablet = false;
}
$webOS = stripos($_SERVER[\'HTTP_USER_AGENT\'],"webOS");
$BlackBerry = stripos($_SERVER[\'HTTP_USER_AGENT\'],"BlackBerry");
$RimTablet= stripos($_SERVER[\'HTTP_USER_AGENT\'],"RIM Tablet");
//do something with this information
if( $iPod || $iPhone ){
//were an iPhone/iPod touch -- do something here
}else if($iPad){
//were an iPad -- do something here
}else if($Android){
//were an Android Phone -- do something here
}else if($AndroidTablet){
//were an Android Phone -- do something here
}else if($webOS){
//were a webOS device -- do something here
}else if($BlackBerry){
//were a BlackBerry phone -- do something here
}else if($RimTablet){
//were a RIM/BlackBerry Tablet -- do something here
}
此代码来自
http://www.schiffner.com/index.php/programming-php-classes/php-mobile-device-detection/您也可以在此处进行全体重训练:
http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/