我有一个非常具体的问题。我正在编写一个手机网页,上面有一个按钮。我在包括IE在内的每个浏览器上都检测到touchevent
,但在IE上它非常具体。几秒钟后,它会自动结束。你能以某种方式帮助我吗?这里是我的代码(修改之一,但仍无法正常工作):在Windows Phone的IE Touchstart事件几秒钟后自动结束
if (window.navigator.pointerEnabled) {
tapButton.addEventListener("pointerup", function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener("pointerdown", function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched = false;
}, false);
alert("pointerEnabled");
}
else if (window.navigator.msPointerEnabled) {
tapButton.addEventListener("MSPointerDown", function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener("MSPointerUp", function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched = false;
}, false);
alert("mspointerEnabled");
}
else {
alert("ordinary touch");
tapButton.addEventListener('touchstart', function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener('touchend', function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched = false;
}, false);
}
和HTML标签中有:
-ms-touch-action: none !important;
touch-action: none !important;
但这并没有帮助。
你没有说你看到的是其中一个版本的IE,但我看到你检测非前缀事件之前,供应商前缀的事件。根据https://msdn.microsoft.com/en-us/library/windows/apps/dn263112.aspx#document_object_model__dom__improvements,不推荐使用前缀版本,只应在非前缀版本不可用时使用。也许重新排序会有所帮助。在某些时候,前缀版本将不再起作用。 –
我试图修复与供应商前缀的问题,但它并没有帮助:(我只用了没有前缀的一个,它是作用于同一:(任何其他建议? – gogachinchaladze
添加工作的代码片段,请,无法理解你的问题。 –