分享一个前端获取浏览器类型的函数

前端
创建时间:2022-04-01 22:59:40

代码

function getBr(){ try { var t = window["opera"] || window.navigator["userAgent"]["indexOf"](" OPR/") >= 0 ? "Opera" : 0, n = "undefined" != typeof InstallTrigger ? "Firefox" : 0, a = Object["prototype"]["toString"]["call"](window["HTMLElement"])["indexOf"]("Constructor") > 0 || window["safari"] && window["safari"]["pushNotification"] && "[object SafariRemoteNotification]" === window["safari"]["pushNotification"]["toString"]() || window["ApplePaySession"]; a = a ? "Safari" : 0; var r = a && window.navigator["userAgent"]["match"]("CriOS") ? "Chrome IOS" : 0, o = window["chrome"] && !t ? "Chrome" : 0, c = window["ActiveXObject"] && "ActiveXObject" in window || window['document']["documentMode"] ? "IE" : 0, f = !c && window["StyleMedia"] ? "Edge" : 0; return t || n || f || c || o || r || a || "" } catch (t) { return null } }

来源

akam 防护脚本中提取的