0

I need to detect mobile devices and I'm using this code, as per this question.

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 // some code..
}

However, it no longer detects Chrome on my iPad. How can mobile Chrome be detected now?

Community
  • 1
  • 1
skyisred
  • 5,937
  • 5
  • 27
  • 51
  • The reason that isn't working is because you don't have the exact user agent. So find your ipad chrome user agent and add it. check this link: https://developer.chrome.com/multidevice/user-agent – floor Sep 12 '15 at 06:12
  • There is only section for chrome on iPhone, but not for ipad – skyisred Sep 12 '15 at 06:29
  • I didn't see it say only for iPhone. iOS is the same of both devices. – floor Sep 12 '15 at 06:31
  • so what should i use for detection string then? – skyisred Sep 12 '15 at 06:33
  • Ah it does say iphone. so it may not work.. but what you could do is write some javascript to console log / alert the user agent when you go to it and see what it says when you use your ipad. then add it to you catch. But whats the goal here to know they are using an ipad or just a mobile device? because you could do what they call feature detection on the tap event. – floor Sep 12 '15 at 06:37
  • only need to detect mobile – skyisred Sep 12 '15 at 06:53
  • Have you tried adding `CriOS`? – uri2x Sep 12 '15 at 07:55

0 Answers0