How to determine if the client is a touch device [duplicate]

You can use the following JS function:

function isTouchDevice() {
   var el = document.createElement('div');
   el.setAttribute('ongesturestart', 'return;'); // or try "ontouchstart"
   return typeof el.ongesturestart === "function";
}

Source: Detecting touch-based browsing.

Please note the above code only tests if the browser has support for touch, not the device.

Related links:

  • How to detect a mobile device using jQuery
  • How to optimize website for touch devices
  • How to detect a mobile device using jQuery
  • What’s the best way to detect a ‘touch screen’ device using JavaScript?
  • Mozilla.org Detecting touch: it’s the ‘why’, not the ‘how’

There may be detection in jquery for mobile and jtouch

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)