Back Javascript

Detecting Android Devices with Javascript

WRITTEN BY ON 23 May 2014

I was working on a website and I realised there's a bug that occurs in Android only. After doing some searches and can't seem to fix the issue except create a conditional statement and do it differently. So here you have it, Android detection Javascript code snippet.

var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
   // Do your thing here
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.