Is it possible to determine the user's device using JS? It does not matter what kind of data will have to operate, as long as you can distinguish one user from another.
- so you need to: determine the user's operating system (or its browser) or get its unique identifier (such as mac-addresses)? the first is simple. - Alexey Obukhov
|
2 answers
The easiest way is to write a random value to localStorage. But if you have a server, it is even easier to use cookies for this purpose.
- Thanks for the tip! - Ilya Bizunov
|
You can define a user agent in the global object navigator.userAgent and you can already recognize it by the agent and recognize the device.
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) { // ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ ΡΠΈΠ΄ΠΈΡ Ρ ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈΠ»ΠΈ ΡΠ°Π±Π»Π΅ΡΠΊΠΈ } |