What is the User Agent string name for Microsoft Edge?

前端 未结 8 2436
無奈伤痛
無奈伤痛 2020-12-05 03:54

I\'m making a website and I want it to be compatible with the forthcoming Microsoft Edge when it comes out officially. To be more specific, the mobile version of it. Does an

8条回答
  •  青春惊慌失措
    2020-12-05 04:30

    For those looking for a regex to detect IE and Microsoft Edge, I repurposed one from another SO answer and added Edge

    /(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:|\bEdge\/)(\d+)/

    I made it check for Edge and then a miscellaneous digit in case they decide to iterate the Edge version.

    EDIT: To update yes, both Edge and older IE versions are considered very different browsers. My use case required detecting IE branded browsers for marketing purposes (if user is using any Internet Explorer/Edge browser, we wanted to show something for that) but that might not necessarily be the case for you.

提交回复
热议问题