JS

HOW TO DETECT MOBILE DEVICES IN JAVASCRIPT

var isMobile = navigator.userAgent .toLowerCase().match(/mobile/i);   if (isMobile) { MOBILE } else { NOT MOBILE }

USER AGENT CHECK

01

var ua = navigator.userAgent .toLowerCase(); var isMobile = ua.match(/mobile/i); var isTablet = ua.match(/tablet/i); var isAndroid = ua.match(/android/i), var isiPhone = ua.match(/iphone/i);

MORE USER AGENT CHECK

02

var md = new MobileDetect (window.navigator.userAgent);   console.log( md.mobile() ); console.log( md.phone() ); console.log( md.tablet() ); console.log( md.os() );

DETECTION LIBRARY

03