gpt4 book ai didi

javascript - 如何区分 iOS7 用户代理字符串中的 Chrome 和 Safari?

转载 作者:行者123 更新时间:2023-12-01 11:09:52 27 4
gpt4 key购买 nike

Useragent 的详细信息不详,或者我没有在正确的地方查找。

navigator.userAgent.match() 而言,iOS7、iPad 或 iPhone 上的 Chrome 和 Safari 有什么区别?

最佳答案

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");
}

引用:https://developers.google.com/chrome/mobile/docs/user-agent

关于javascript - 如何区分 iOS7 用户代理字符串中的 Chrome 和 Safari?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19106645/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com