Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to differentiate between userAgents?

As the title says…

This is a userAgent in Safari (MacOS):
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15

and then here is the same in Chrome (MacOS):
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How am I supposed to tell which is which browser?

An escape route I found is window.chrome vs. window.safari as these are only defined in their own browser as the name suggests.

If anyone knows a somewhat more reliable or more detailed method to check these please let me know. 🙂

>Solution :

The point isn’t to differentiate by name, because new browsers can pop up any time. You’re supposed to test functionality before using it, and to write most (if not all) of your page in a cross-browser way. You can use polyfills or libraries like jQuery and let them figure out how to fill in the blanks.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading