We have a list of browsers we test our webapp in. I have a task to notify the user if his browser isn't supported or tested to work well with our app.
We have a browserslist
configuration in the project and I'm looking for a way to test current browser against the list.
I tried browserlist-useragent
but we can't compile it with webpack due to the fact it uses net
, fs
, tls
and other native node modules we don't want to include in our bundle.
Is there any better way do avoid copying the list of supported browsers in many different places and just use browserlist configuration that already exists to detect if user uses supported one or not?
In the menu bar at the top of your screen, click Help and then select About Internet Explorer. The browser version will be displayed on the screen. Or: On the upper-right corner of the browser window, click the gear icon.
To detect user browser information we use the navigator. userAgent property. And then we match with the browser name to identify the user browser. Now call this JS function on page load, and this will display the user browser name on page load.
Supported Web Browser means the current release of Microsoft Edge, Mozilla Firefox, Google Chrome, Apple Safari, or any other web browser that the Provider agrees in writing shall be supported.
appName returns the string “Mozilla Firefox”. If it is Edge, navigator. appName returns the string “Microsoft Edge”. Using both objects, we can create an alert box to display what web browser the client is using and this navigator object contain all the information about web browser version, name, and more.
I'd consider using this "utility" package https://github.com/browserslist/browserslist-useragent-regexp
in the project that uses browserslist
, and then use the file generated by the script suggested by this package to then use anywhere else.
In reality, all you want is the regex in the generated file. This can be placed in any client or server code you need for browser detection. I've placed mine in some classic asp.
Also note that on a Windows PC, the instructions provided don't result in a file containing a RegEx. Instead, you'd need to run npx browserslist-useragent-regexp --allowHigherVersions
to display a suitable RegEx on your console, and then add that where needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With