Is there a way to distinguish a real mobile device from a device emulated by Google Chrome? Please note that Google Chrome can emulate Useragent, touchscreen, screen resolution and accelerometer. I need to know some features which cannot be emulated but can be detected by javascript.
Asked
Active
Viewed 5,918 times
15
-
1Why would you want something like this? (Just of curiosity) – Ali Naci Erdem Jan 22 '15 at 07:57
-
which feature do you want to access that can not be emulated? – JeanLuc Jan 22 '15 at 07:59
-
1did you check "window.navigator" property. – techierishi Jan 22 '15 at 08:04
-
Is there a particular device you are looking to differentiate (e.g. iPhone)? The approach will be different for different devices – Rob M. Jan 22 '15 at 08:12
-
2`navigator.vendor` always return `Google Inc.` even emulate iPhone. – colder Jun 22 '17 at 17:42
-
@AliNaciErdem this is useful when making hybrid apps (supporting browser/web app and mobile device app), sometimes you want to load libraries/scripts based on whether in browser or smart device app. Example: cordova.js – ekerner Mar 08 '18 at 09:35
1 Answers
6
It is possible to check for navigator.plugins.length. Mobile browsers have no plugins, so navigator.plugins.length is equal to 0; Desktop browsers ordinary have plugins, so we can distinguish browsers by length of plugins array.

Sergey Kravchenko
- 957
- 1
- 8
- 21
-
9
-
4This no longer works. `navigator.plugins.length === 0` on Chrome when it's emulating iOS. – fregante Jun 18 '16 at 13:09
-
var isSmartDevice = /* mobile if android or iOS and not emulated in mac or win pc (for dev) \*/ (navigator.userAgent.match(/(android|ip(hone|ad|od))/i) && (!navigator.platform || !navigator.platform.match(/(win|mac)/i))) /* or if windows phone or blackberry (no dev in windows) */ || navigator.userAgent.match(/(windows phone|iemobile|wpdesktop|blackberry)/i); – ekerner Mar 08 '18 at 09:29
-
-
4The definitive way to determine this is to check for `navigator.maxTouchPoints > 1` Because Chrome emulated devices will always have only 1 touchpoint (ie. your mouse cursor), while actual (modern) mobile devices will always have more than 1, and devices without touch support will always have 0. You're welcome. – Ivan Apr 28 '20 at 08:16
-
@Ivan what would happen when someone using Chrome on laptop with touchscreen support? – blackbiron Nov 14 '20 at 16:52
-
3@blackbiron I tested this: I have verified that `navigator.maxTouchPoints` is 10 on a touch screen computer when mobile emulation is *not* running, but it is 1 when mobile emulation is running. So that's good news. – Marc Durdin May 13 '21 at 04:14
-