我试图了解如何检测用户在移动狩猎中打开我的站点的时间。Chrome和safari具有绝对相同的参数: Chrome "Mozilla/5.0 (iPad;CPU OS 8_1_2,如Mac ) AppleWebKit/600.1.4 (KHTML,类似壁虎)版本/8.0 Mobile/12B440 Safari/600.1.4“safari "Mozilla/5.0 (iPad;CPU OS 8_1_2类似Mac ) AppleWebKit/600.1.4 (KHTML,类似Gecko)版本/ Mobile/12B440 Safari/600.1.4”有没有任何方法来检测移动安全?
发布于 2015-07-16 15:25:57
开发者Chrome网站声明:
Chrome中的UA与Mobile用户代理相同,带有CriOS/而不是Version/< VersionNum>。
因此,正确的useragent检查将是:
var ua = navigator.userAgent;
if (ua.match(/(iPod|iPhone|iPad)/) !== null && ua.match(/AppleWebKit/) !== null && ua.search('CriOS') < 0) {
alert("You are using Mobile Safari!");
} else {
alert("Whatever this is, it's not Mobile Safari...");
}这是小提琴- https://jsfiddle.net/h8j9n2m5/1/.在iPad iOS 7.0.4,MobileSafari7.0上查看了一下,效果很好:)
https://stackoverflow.com/questions/27932133
复制相似问题