Last active
July 20, 2018 16:15
-
-
Save alejandrorangel/e6c31177047dbcc16ae512f02064edd7 to your computer and use it in GitHub Desktop.
This file contains 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 detectBrowser(userAgent){ | |
var chrome = /.*(Chrome\/).*(Safari\/).*/g; | |
var firefox = /.*(Firefox\/).*/g; | |
var safari = /.*(Version\/).*(Safari\/).*/g; | |
var opera = /.*(Chrome\/).*(Safari\/).*(OPR\/).*/g; | |
var edge = /.*(Chrome\/).*(Safari\/).*(Edge\/).*/g; | |
var ie = /.*(Trident\/7).*(rv:).*/g; | |
if(opera.exec(userAgent)) | |
return "Opera"; | |
if(edge.exec(userAgent)) | |
return "Edge"; | |
if(chrome.exec(userAgent)) | |
return "Chrome"; | |
if(safari.exec(userAgent)) | |
return "Safari"; | |
if(firefox.exec(userAgent)) | |
return "Firefox"; | |
if(ie.exec(userAgent)) | |
return "Internet Explorer"; | |
return "not supported"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment