触控 API(例如 touchstart)在 MS Edge 中不起作用 [英] Touch API (e.g. touchstart) not working in MS Edge

查看:13
本文介绍了触控 API(例如 touchstart)在 MS Edge 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用 Touch API 来检测 JavaScript 中的触摸事件.示例:

my application is using the Touch API to detect touch events in JavaScript. Example:

$(".element").on("touchstart", function(event){
    alert("TRUE");
});

这适用于任何带有任何浏览器(如 Android 或 iOS)的触摸设备,但它不适用于带有或不带有连接键盘的 Windows 10 平板电脑上的 MS Edge.似乎支持 API:兼容性列表.但是,我已经测试过:'ontouchstart' in window 并且在此设备上返回 false.此外 mousedown 似乎被解雇了.

This works on any touch device with any browser like Android or iOS, however it doesn't work in MS Edge on a Windows 10 Tablet with or without conntected keyboard. The API seems to be supported: Compatibility list. However, I've tested: 'ontouchstart' in window and this returns false on this device. Furthermore mousedown seems to get fired.

这里发生了什么?如何在 Windows 10 平板电脑上触发触摸事件?我想仅针对触摸设备保留该事件.切换到指针事件 API 还包括桌面设备,这不是我想要的.

What is going on here? What can I do to fire touch events on a Windows 10 tablet? I would like to keep the event only for touch devices. Switching to the Pointer Events API would include also Desktop devices and that is not what I want.

推荐答案

对于触摸 API,您必须在 Edge 上激活一个标志:在地址栏中,输入 about:flags 并按 Enter.在 Touch 部分,您可以使用相应的下拉菜单启用触摸事件

for touch API, you have to activate a flag on Edge : in the address bar, enter about:flags and press enter. In the section Touch, you can enable touch events with the corresponding dropdown

这篇关于触控 API(例如 touchstart)在 MS Edge 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆