What is the user agent string for surface rt?

后端 未结 7 2106
感动是毒
感动是毒 2020-12-29 04:44

I\'m trying to determine the user agent string for surface RT for testing purposes.

7条回答
  •  天涯浪人
    2020-12-29 04:53

    UserAgent for devices -

    IE desktop - "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; rv:11.0) like Gecko"

    IE Surface Pro - "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; Tablet PC 2.0; rv 11.0) like Gecko"

    Edge desktop - "Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063"

    Edge surface - "Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"

    By looking at the above user agents we don't have any clear distinguish between desktop and surface pro for Edge(IE is having Tablet PC check available ). So here to detect the window device first(surface pro is window tablet) and then verify if the device is touch device.

    window + touch: true - surface pro

    window + touch: false - desktop

    isSurface: function () {
      // Window device Check
      if(!!navigator.userAgent.match(/Win/)) { 
      // Check if the device is touch               
      return !!navigator.userAgent.match(/Tablet PC/i) || "ontouchstart" in document.documentElement; 
      }
    }
    

提交回复
热议问题