Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  9] [ 2]  / answers: 1 / hits: 22489  / 13 Years ago, fri, january 6, 2012, 12:00:00

Today (or very recently) Chrome Beta updated to 17 for me and with it i noticed some funkiness in my web app. I noticed it was because a class was being added to the body element that normally only gets put there if there is touch event support which I check like this:



  try {  
document.createEvent(TouchEvent);
_device.touch = true;
} catch (e) {
_device.touch = false;
}


And sure enough, i can create and trigger touch events on Chrome 17. First idea i had was, oh, i can check for touch, and see if a mouse click fails, therefore, there's a mouse, but MouseEvents trigger too.



How else can I check, without user agent sniffing, that it's an actual, touchable, device, and not just a browser that supports touch events.


More From » jquery

 Answers
5

Try:



'ontouchstart' in document.documentElement

[#88181] Thursday, January 5, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dantel

Total Points: 7
Total Questions: 102
Total Answers: 97

Location: Saint Lucia
Member since Sat, Jun 6, 2020
4 Years ago
;