它是简单的从navigator.userAgent的navigator.userAgent的非智能设备
检测智能设备像navigator.userAgent.match(/ iPhone/I),navigator.userAgent.match(/的Android/I)等
我如何知道请求来自系统(非智能设备),如从台式机,笔记本电脑等。使用navigator.userAgent。
它是简单的从navigator.userAgent的navigator.userAgent的非智能设备
检测智能设备像navigator.userAgent.match(/ iPhone/I),navigator.userAgent.match(/的Android/I)等
我如何知道请求来自系统(非智能设备),如从台式机,笔记本电脑等。使用navigator.userAgent。
您可以测试userAgent
值的流行浏览器的名称!例如,对于Firefox的最新版本的用户代理字符串看起来是这样的:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Browser detection is bad。相反,选择feature detection总是更好。
我不想检测浏览器,我想检查来自智能设备或某个非智能设备的请求 –
检测浏览器可以告诉您用户是在PC还是智能设备上使用浏览器。如果您不想查找浏览器字符串,为什么不简单地将您的支票转换为智能设备?如果用户代理说它不是任何智能设备,那么它必须是另一台设备 - 大多数情况下可能是一台计算机! – AndyBursh