JSFiddle - React, Tailwind, and code Playground
by mattography
JavaScript
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
WindowsPhone: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (!isMobile.Android() || !isMobile.iOS() || !isMobile.Windows());
}
};
if(isMobile.WindowsPhone()) {
alert("Windows Phone");
}
if(isMobile.Android()){
alert("Android");
}
if(isMobile.any()){
alert("non-mobile device");
}