jquery中的便携式设备检测

jquery中的便携式设备检测,jquery,mobile,detection,Jquery,Mobile,Detection,我的问题是如何在jquery中检测客户端是否从移动设备上看到网站。这包括任何便携式设备(手机、i-pad、i-phone、adroid、windows等) 谢谢您的时间。实际上,您可以在纯javscript中嗅探用户代理,jQuery建议做的一件事是不要检查用户代理,但您应该检查支持的功能。为此,jquery提供 对于大多数情况,现代化的可能复制也是一个很好的解决方案 var deviceIphone = "iphone"; var deviceIpod = "ipod"; //Initial

我的问题是如何在jquery中检测客户端是否从移动设备上看到网站。这包括任何便携式设备(手机、i-pad、i-phone、adroid、windows等)


谢谢您的时间。

实际上,您可以在纯javscript中嗅探用户代理,jQuery建议做的一件事是不要检查用户代理,但您应该检查支持的功能。为此,jquery提供

对于大多数情况,现代化的可能复制也是一个很好的解决方案
var deviceIphone = "iphone";
var deviceIpod = "ipod";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current device is an iPhone.
function DetectIphone()
{
   if (uagent.search(deviceIphone) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPod Touch.
function DetectIpod()
{
   if (uagent.search(deviceIpod) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPhone or iPod Touch.
function DetectIphoneOrIpod()
{
    if (DetectIphone())
       return true;
    else if (DetectIpod())
       return true;
    else
       return false;
}