--- title: GlobalEventHandlers.ontouchstart slug: Web/API/GlobalEventHandlers/ontouchstart translation_of: Web/API/GlobalEventHandlers/ontouchstart ---
{{event("touchstart")}} 事件的{{domxref("GlobalEventHandlers","全局事件处理器")}}.
{{SeeCompatTable}}
备注: 这个属性尚未正式标准化。它被定义在{{SpecName('Touch Events 2')}} {{Spec2('Touch Events 2')}} 规格中,但并没有被定义在 {{SpecName('Touch Events')}} {{Spec2('Touch Events')}}中。这个属性尚未被完成实现。
var startHandler = someElement.ontouchstart;
startHandler
someElement的touchstart事件处理函数
.这个例子展示了使用ontouchstart属性的两种方法。
<html> <script> function startTouch(ev) { // 处理事件 } function init() { var el=document.getElementById("target1"); el.ontouchstart = startTouch; } </script> <body onload="init();"> <div id="target1"> Touch me ... </div> <div id="target2" ontouchstart="startTouch(event)"> Touch me ... </div> </body> </html>
规范 | 状态 | 评论 |
---|---|---|
{{SpecName('Touch Events 2','#widl-GlobalEventHandlers-ontouchstart')}} | {{Spec2('Touch Events 2')}} | Non-stable version. |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(18.0)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |