4

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

_android = navigator.userAgent.toLowerCase().indexOf("android");

_iOS = navigator.platform.indexOf("iPhone");

My task is to identify if device is win8 tablet or not?

I have already seen this post. But, the string "Windows NT" is likely to appear in useragent on all the PC browsers. So, I need to find out a client side way of identifying if device is win8 tablet?

Any thoughts?

Community
  • 1
  • 1
hrishikeshp19
  • 8,838
  • 26
  • 78
  • 141
  • This is not exactly an answer to your question, but if you're identifying devices in order to adapt to their capabilities, you should query their capabilities instead. Google 'browser feature detection' – GreyBeardedGeek Jan 09 '13 at 00:43

2 Answers2

5

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.

Dominic Hopton
  • 7,262
  • 1
  • 22
  • 29
  • 4
    if (navigator.platform.toLowerCase().indexOf("win") !== -1 && navigator.userAgent.toLowerCase().indexOf("touch") !== -1) { return "its win8 tablet" }; did the trick for me. I am still investigating on more definitive way of determining out the win8 tablet. – hrishikeshp19 Jan 10 '13 at 02:57
5

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

Ra.
  • 2,499
  • 3
  • 28
  • 41