Read more

How to detect touch-capable browsers

Dominik Schöler
February 18, 2015Software engineer at makandra GmbH

The easiest way to detect touch-capable browsers is to check for the presence of touch events. It is no 100% solution, but has by far the best cost-benefit ratio. (Know that this does not detect touch devices, but browsers.)

Javascript

var isTouchDevice = 'ontouchstart' in window

Coffeescript

isTouchDevice = 'ontouchstart' of window
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

On the difference between the Javascript and the Coffeescript version, see Beware: Coffeescript "in" is not the Javascript "in".

Posted by Dominik Schöler to makandra dev (2015-02-18 14:30)