I'm trying to use javascript to detect if my visitor is on a touch device or not.
I have the following...
function is_touch_device() {
return 'ontouchstart' in window || 'onmsgesturechange' in window;
}
The above works fine apart from ie11 is returning true, that it is a touch device when in reality it isnt. Has anybody experienced this before?
The following code snippet might help:
function is_touch_device() {
return (('ontouchstart' in window)
|| (navigator.maxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
//navigator.msMaxTouchPoints for microsoft IE backwards compatibility
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With