This question already has an answer here:
- How can you detect the version of a browser? 23 answers
How do I determine the exact browser and version using JavaScript?
This question already has an answer here:
How do I determine the exact browser and version using JavaScript?
This little library may help you. But be aware that browser detection is not always the solution.
Instead of hardcoding web browsers, you can scan the user agent to find the browser name:
I've tested this on Safari, Chrome, and Firefox. Let me know if you found this doesn't work on a browser.
"Safari"
"Chrome"
"Firefox"
You can even modify this to get the browser version if you want. Do note there are better ways to get the browser version
Sample output:
Since Internet Explorer 11 (IE11+) came out and is not using the tag name of
MSIE
anymore I came up with a variance of an older detection function:Some times we need simple method to check if the browser is IE or not. This is how it could be:
or simplified siva's method:
MSIE v.11 check:
other IE browsers contain MSIE string in their userAgent property and could be catched by it.
Below code snippet will show how how you can show UI elemnts depends on IE version and browser
Below code will give how we can get IE version
I make this small function, hope it helps. Here you can find the latest version browserDetection