bug*_*net 2 javascript safari user-agent google-chrome ios7
有用的细节是粗略的,或者我没有找到正确的地方.
就a而言,什么navigator.userAgent.match()可以区分iOS7,iPad或iPhone上的Chrome和Safari?
小智 10
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");
}
Run Code Online (Sandbox Code Playgroud)
参考:https://developers.google.com/chrome/mobile/docs/user-agent