Touch API(例如touchstart)无法在MS Edge中运行 [英] Touch API (e.g. touchstart) not working in MS Edge

查看:141
本文介绍了Touch 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',这在此设备上返回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键。在触摸部分,您可以使用相应的下拉列表启用触摸事件

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

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

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