Detect mobile browser
- how to check browser type in javascript
- how to check browser version in javascript
- how to check browser in javascript
- check type in javascript
Check if browser is safari
Javascript detect internet explorer.
# Table of Contents
- Get Browser name (Chrome, Firefox, Safari) using
#
To get the browser name (e.g.
- Use the navigator.userAgent property to get the user agent string for the current browser.
- Use the method to check if a regular expression matches the user agent string for each browser.
Here is the HTML for the example.
Copied!
The code for this article is available on GitHub
Copied!
The code for this article is available on GitHub
You can start a basic development server by opening your terminal in the same directory as the and files and issuing the following command.
If I load the example in Chrome, I get the following output.
And here is a screenshot of opening the page in Firefox.
The navigator.userAgent property returns the user agent string for the current browser.
Copied!
The name of the browser is located toward the end of the user agent string (e.g.
Chrome or Firefox).
We used the RegExp.test() method to check if the user agent string contains specific substrings.
The forward slashes mark the start and the end of the regular e
- check browser type