safari navigator.userAgent值为:
mozilla/5.0(iphone;cup iphone os 6_0_1 like mac os x) applewebkit/536.26(khtml,like gecko) version/6/0 mobile/10a523 safari/8536.25
chrome navigator.userAgent值为;
mozilla/5.0(iphone;cup iphone os 6_0_1 like mac os x;zh_cn) applewebkit/536.26(khtml,like gecko) crios/21.0.1180.82 mobile/10a523 safari/8536.25(ff287424-702f-4250-a992-0172ef5859d5)
通过
ua = navigator.userAgent.toLowerCase();
safari = /safari/.test(ua);
不能判断是否是safari浏览器
判断mobile safari 浏览器方案:
mobileSafari = (/iPhone/i.test(navigator.platform) || /iPod/i.test(navigator.platform) || /iPad/i.test(navigator.userAgent)) && !!navigator.appVersion.match(/(?:Version\/)([\w\._]+)/);