according to What's the best way to detect a 'touch screen' device using JavaScript? I implemented a touch device detection using
((!!('ontouchstart' in window) ? 1 : 0) == 1)
This statement nicely returns true or false, also in the newest Chrome Browser (v17); just as stated. To beautify my code a bit, a put this statement into a small function
function isTouchDevice() {
return ((!!('ontouchstart' in window) ? 1 : 0) == 1);
};
Unfortunately this function falsely returns TRUE on Chrome 17, whereas (as stateted above), the statement itself works correctly, if called inline or directly from console.
Others browsers (IE, FF) do not return wrong results.
Can anybody explain?