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?
var 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.com/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.