User agent, extract OS and browser from string

前端 未结 3 1761
难免孤独
难免孤独 2021-01-13 09:48

I\'d like to extract full the OS name and browser from the user agent string. How can I do this?

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 10:19

    I think it is tricky to get the full OS name and full browser name since many browsers identify themselves differently. You will probably need some fancy regex and then it might not even work 100% of the time.

    Here is the simple method I use to identify the browser. You may be able to adapt it to suit your needs.

提交回复
热议问题