Posted By

jpdevries on 08/03/10


Tagged

touch


Versions (?)

isTouchDevice()


 / Published in: JavaScript
 

Google Chrome 5.0.375.125 on Mac OS X 10.6 presents itself returns true for this function, even though its not really a touch device?

  1. function isTouchDevice() {
  2. var el = document.createElement('div');
  3. el.setAttribute('ontouchmove', 'return;');
  4. if(typeof el.ontouchmove == "function"){
  5. return true;
  6. }else {
  7. return false
  8. }
  9. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bayxsonic on August 4, 2010

Or the shorter: function isTouchDevice() { var el = document.createElement('div'); el.setAttribute('ontouchmove', 'return;'); return typeof el.ontouchmove == "function"; }

You need to login to post a comment.