I've looked about the web, and except perhaps for one or more old versions of Chrome which might give a false positive on it I see that this is probably a quick and easy way to detect a touch device:
I'm not worried about old versions of Chrome as they update their browser mostly automatically without user intervention, anyone stuck with an older version has likely done so intentionally. And the consequences of a false positive are minimal in my planned usage of it anyway, as long as it works in the vast majority of cases. I get no false positive in my current version of Chrome.Code:var touchcabable = 'ontouchstart' in document.documentElement;
Here's the test page, I'm particularly interested in touch capable browsers of all kinds as I have none to test on, but any feedback as to the accuracy or lack thereof of the two report lines on this page is welcome:
http://home.comcast.net/~jscheuer1/s...line/touch.htm
There are just two lines:
They of course both say is not for me, as I'm on an ordinary laptop running Win 7. If you have a touch device they should be:1.) On the first parse of the head this device/browser is not touch enabled
2.) On document ready this device/browser is not touch enabled
I used two statements just in case some devices couldn't report correctly until after the full page was parsed (#2).1.) On the first parse of the head this device/browser is touch enabled
2.) On document ready this device/browser is touch enabled
Like I said, please let me know what happens, and please include browser, device, OS, including version numbers for each of those.



Reply With Quote




Bookmarks