Created
November 25, 2020 02:31
-
-
Save hendrasyp/816e34a06db5ad28743126c68de68158 to your computer and use it in GitHub Desktop.
Check Client Browser Detail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function browserClientInfo() { | |
"undefined" != typeof jQuery ? console.log("jQuery Version", jQuery.fn.jquery) : console.log("jQuery library is not found!"); | |
navigator.appVersion; | |
var n, e, r, o = navigator.userAgent, a = navigator.appName, i = "" + parseFloat(navigator.appVersion), | |
s = parseInt(navigator.appVersion, 10); | |
-1 != (e = o.indexOf("OPR/")) ? (a = "Opera", i = o.substring(e + 4)) : -1 != (e = o.indexOf("Opera")) ? (a = "Opera", i = o.substring(e + 6), -1 != (e = o.indexOf("Version")) && (i = o.substring(e + 8))) : -1 != (e = o.indexOf("MSIE")) ? (a = "Microsoft Internet Explorer", i = o.substring(e + 5)) : -1 != (e = o.indexOf("Chrome")) ? (a = "Chrome", i = o.substring(e + 7)) : -1 != (e = o.indexOf("Safari")) ? (a = "Safari", i = o.substring(e + 7), -1 != (e = o.indexOf("Version")) && (i = o.substring(e + 8))) : -1 != (e = o.indexOf("Firefox")) ? (a = "Firefox", i = o.substring(e + 8)) : (n = o.lastIndexOf(" ") + 1) < (e = o.lastIndexOf("/")) && (a = o.substring(n, e), i = o.substring(e + 1), a.toLowerCase() == a.toUpperCase() && (a = navigator.appName)), -1 != (r = i.indexOf(";")) && (i = i.substring(0, r)), -1 != (r = i.indexOf(" ")) && (i = i.substring(0, r)), s = parseInt("" + i, 10), isNaN(s) && (i = "" + parseFloat(navigator.appVersion), s = parseInt(navigator.appVersion, 10)), console.log("Cookie Enabled", navigator.cookieEnabled), console.log("Browser: ", a + "(" + i + ")"), console.log("Navigator: ", navigator.appName), console.log("User Agent: ", navigator.userAgent); | |
var t = "Unknown OS"; | |
-1 != navigator.appVersion.indexOf("Win") && (t = "Windows"), -1 != navigator.appVersion.indexOf("Mac") && (t = "MacOS"), -1 != navigator.appVersion.indexOf("X11") && (t = "UNIX"), -1 != navigator.appVersion.indexOf("Linux") && (t = "Linux"), console.log("OS: ", t) | |
} | |
function checkBrowser(){ | |
c = navigator.userAgent.search("Chrome"); | |
f = navigator.userAgent.search("Firefox"); | |
m8 = navigator.userAgent.search("MSIE 8.0"); | |
m9 = navigator.userAgent.search("MSIE 9.0"); | |
if (c > -1) { | |
browser = "Chrome"; | |
} else if (f > -1) { | |
browser = "Firefox"; | |
} else if (m9 > -1) { | |
browser ="MSIE 9.0"; | |
} else if (m8 > -1) { | |
browser ="MSIE 8.0"; | |
} | |
return browser; | |
} | |
if (checkBrowser() !== "Firefox"){ | |
//window.location.href = "/dashboard"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment