by iron_ball · 12y ago · 0 comments
function isMobile() {
return navigator.userAgent.toLowerCase().indexOf("mobile")>=0;
}
This is really the best we can do after twenty years of the WWW?In JVM land I've had pretty good success with UADetector [1] for delivering device specific content to mobile phones and desktop/laptop/tablets.
/mobile/i.test(navigator.userAgent)Just because the API call and syntax is a bit iffy doesn't mean it's a bad pattern. ES6 will finally have a string .contains method btw (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...)