I've been given some code for detecting if a user is using a mobile device or a desktop.
var user_agent = navigator.userAgent;
var mobile = /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i;
if (!mobile.test(user_agent)) {
$(".master-content").css({"width":"1280px","margin":"0 auto","overflow-y":"visible"});
$(".off-canvas-wrap").css({"overflow":"visible"});
}
Can anyone tell me of a more reliable way to do this, or at least why this is a bad way for doing device detection?
Thanks