Question

I'm developping a website that is offering a different navigation depending on if the user is browsing on a Smartphone (with touch screen) or on a computer. Actually, the check is done through Modernizr.touch but I want touch-screen computers to act like others.

Does someone has an idea of how to reach that ?

Was it helpful?

Solution

Try this:

For detecting touch devices(including touchscreen monitor)

var is_touch_device = 'ontouchstart' in document.documentElement;
if(is_touch_device){
   //code for touch devices
}

for only detecting mobile devices:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 //code for touch devices
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top