admin管理员组文章数量:1353322
Useragent details are sketchy, or I'm not looking in the right places.
What, in terms of a navigator.userAgent.match()
, would differentiate between Chrome and Safari on iOS7, iPad or iPhone?
Useragent details are sketchy, or I'm not looking in the right places.
What, in terms of a navigator.userAgent.match()
, would differentiate between Chrome and Safari on iOS7, iPad or iPhone?
2 Answers
Reset to default 11var ua = navigator.userAgent;
var matches = ua.match(/^.*(iPhone|iPad).*(OS\s[0-9]).*(CriOS|Version)\/[.0-9]*\sMobile.*$/i);
if (!matches) console.log("Not what we're looking for.");
else {
console.log(matches[1]);
if (matches[2] === 'OS 7') console.log(matches[2]);
else console.log('Not the right version.');
if (matches[3] === 'CriOS') console.log("Chrome");
else console.log("Safari");
}
Reference: https://developers.google./chrome/mobile/docs/user-agent
Not sure about iOS, never had a device, but under Windows Chrome has a window.chrome
object defined. Check for it existence and if it's there - you're in Chrome.
If similar approach works under iOS (I think it should) then u don't need to check UserAgent.
版权声明:本文标题:javascript - How does one differentiate between Chrome and Safari in an iOS7 useragent string? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743892633a2557205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论