[英]IE10 is not Handling Click Events | Help Using MSPointer
Please forgive me in advance for being a stoopid noob. 请原谅我作为一个stoopid菜鸟。
Anyway, I'm trying to make my html5 game play on IE10, but it's not detecting my clicks. 无论如何,我正试图在IE10上制作我的html5游戏,但它没有检测到我的点击。
So I research this a bit and find out that instead of understanding what this means: 所以我研究了一下,发现它不是理解这意味着什么:
document.getElementById("answer1").addEventListener("click", wrong, false);
If have to use some crappy proprietary code. 如果必须使用一些蹩脚的专有代码。 Because I am a stoopid noob, I am having problems implementing this.
因为我是一个stoopid菜鸟,我在实施这个问题时遇到了问题。
Here is what I have currently 这是我目前的情况
document.getElementById("answer1").addEventListener("click", wrong, false);
document.getElementById("answer2").addEventListener("click", wrong, false);
document.getElementById("answer3").addEventListener("click", wrong, false);
document.getElementById("answer4").addEventListener("click", wrong, false);
//Stupid IE10 Crap
if (window.navigator.msPointerEnabled) {
document.getElementById("answer1").addEventListener("MSPointerDown", wrong, false);
document.getElementById("answer2").addEventListener("MSPointerDown", wrong, false);
document.getElementById("answer3").addEventListener("MSPointerDown", wrong, false);
document.getElementById("answer4").addEventListener("MSPointerDown", wrong, false);
}
When I run the code on ie10, it still doesn't register my mouse clicks. 当我在ie10上运行代码时,它仍然没有注册我的鼠标点击。 Am I missing something or doing something incorrectly?
我错过了什么或做错了吗?
Please assist me. 请帮助我
Well, I do not why it wasn't working. 好吧,我不知道为什么它不起作用。 It's still not working.
它仍然无法正常工作。
But I found a workaround that I thought that I would share. 但我找到了一个我认为可以分享的解决方法。 I added the following attributes to CSS of the target DIVs.
我将以下属性添加到目标DIV的CSS中。
background-color:#FFFFFF; opacity:0;
For some reason, if I give the DIVS a background color and make them totally transparent, the clicks register. 出于某种原因,如果我给DIVS一个背景颜色并使它们完全透明,则点击注册。
So, I'm done caring about this problem for now. 所以,我现在已经完成了对这个问题的关心。
I hope this helps someone. 我希望这可以帮助别人。
On each of those elements, add the css style -ms-touch-action: none;
在每个元素上,添加css样式
-ms-touch-action: none;
IE10 seems to expect that on elements you want the Pointer events to interact with, so that it doesn't try to maintain default browser behavior. IE10似乎期望在你希望Pointer事件与之交互的元素上,这样它就不会尝试维护默认的浏览器行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.