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 ?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.