2013-06-24 116 views

回答

2

我只是在谷歌搜索,这里是第一个结果:

http://mobiledetect.net/

include 'Mobile_Detect.php'; 
$detect = new Mobile_Detect(); 

// Check for any mobile device. 
if ($detect->isMobile()) 

// Check for any tablet. 
if($detect->isTablet()) 

// 3. Check for any mobile device, excluding tablets. 
if ($detect->isMobile() && !$detect->isTablet()) 
1

使用此代码用于检测移动设备,然后重定向它: -

<script> 
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) { 
window.location = "m.domain.com"; 
} 
</script> 

test()方法已被用于测试字符串中的匹配,并且如果找到匹配,则发生重定向。将此代码添加到页面的顶部。

+0

@ vivek以及如何重定向到移动版本......它会更好,如果你能给我整个代码 –

+0

@Amarjeet看到我更新的答案。它只是几行解决方案。 –

+0

@ vivek感谢您的帮助。但是您能否告诉我该代码包含哪些内容?以及是否需要包含此代码的任何其他内容。 –

相关问题