How do you detect non-mouse devices in javascript/php?

Discussion in 'JavaScript' started by rajmv, Mar 22, 2012.

  1. #1
    Hi Folks.

    At http://mediabeez.ws, I offer a free and opensourced menu component, that currently doesn't work on iPads, because iPads don't give mouseover events. All you get is a click event, if I understand correctly.

    How would I detect such devices, preferably in javascript, or else in PHP..
    And a list of user agents to detect would be my least favorite option actually, because those will change so quickly..

    Thanks in advance for any help you might provide! :)
     
    Solved! View solution.
    rajmv, Mar 22, 2012 IP
  2. #2
    Have a look at this:

    modernizr.github.com/Modernizr/touch.html

    They have several ways of detecting touch. For example, the first one they have would be:

    var isTouch = 'ontouchstart' in window;
     
    mark2048, Mar 22, 2012 IP