how to identify if user agent is windows 8 tablet?

后端 未结 2 1770
难免孤独
难免孤独 2021-01-06 10:16

I have a web application. I my JavaScript, I am identifying devices by user agent string as follows:

_android = navigator.userAgent.toLowerCase().indexOf(\"a         


        
相关标签:
2条回答
  • 2021-01-06 10:28

    You can't identify if it is a tablet or not, but you can identify if it has touch or not. This is the IE user agent here:

    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; Touch)
    

    The touch at the end is only present if touch is.

    However, if you are just trying to identify touch capabilities, you should use feature detection rather than user agent sniffing.

    0 讨论(0)
  • 2021-01-06 10:38

    User-agent string (Windows) : http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx

    0 讨论(0)
提交回复
热议问题