I want specific keys so that i can make a distinction between the devices using user-agent string. 1. Laptop/Desktop 2. IOS 3. Android 4. Other handsets (BB, Nokia, MS Mobile)
Asked
Active
Viewed 1,411 times
0
-
1) Laptop/Desktop will not have mobile in their UA – Scary Wombat Jan 24 '14 at 06:53
-
ok thanks for that, what about the other mobile devices – kharevbv Jan 24 '14 at 06:54
-
1http://stackoverflow.com/questions/12606245/detect-if-browser-is-running-on-an-android-or-ios-device – nswamy Jan 24 '14 at 06:55
1 Answers
0
You can detect mobile devices using regular expressions on the User-Agent:
90% of the mobile devices can be detected using
/Mobile|Android|BlackBerry/
If you want to detect around 98% of mobile devices you can use this one:
/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/
You can use a subset of the last regex to target specific ones.
About detecting between desktop and laptop it is just NOT possible using user-agent. You need additional information that it is not in the UA such as macaddr or model name.

Adrian
- 9,102
- 4
- 40
- 35