开发者

Google Chrome touch events not firing

开发者 https://www.devze.com 2023-01-18 21:53 出处:网络
I\'m building a touchscreen kiosk using Chrome (7.0.536.2 dev) in kiosk mode on a Windows 7 PC with multi-touch display.

I'm building a touchscreen kiosk using Chrome (7.0.536.2 dev) in kiosk mode on a Windows 7 PC with multi-touch display.

I can see that the ontouchstart event is available (by inspecting the window object in Webkit Web Inspector) but it never fires. If I write the following code, the 开发者_Go百科onclick event fires when I touch the screen but the ontouchstart event doesn't.

window.onclick = function() { alert("click"); }
window.ontouchstart = function() { alert("touchstart"); }

In Firefox 4 the MozTouchDown event fires without any problems.

Are these events not yet available to JavaScript?


I experienced this when developing an iPad webapp and tried to test it in Chrome. It turned out, that Chrome recognizes those events, but does not fire them at the moment. This is a bit frustrating, since it breaks support detection in JavaScript.


There is a command-line switch to enable touch events, change your shortcut adding "chrome.exe --enable-touch". Unfortunately, if ('ontouchstart' in window) returns true then, event is never fired. Just tested this on a Windows7 touch-enabled tablet on canary channel. Disappointing... !


as of chrome 20, you can enable touch events from the "about://flags" internal experiments webpage

I did notice that this breaks fastClick, if you're using that - I was :)

0

精彩评论

暂无评论...
验证码 换一张
取 消