最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - IE10 is not Handling Click Events | Help Using MSPointer - Stack Overflow

matteradmin3PV0评论

Please forgive me in advance for being a stoopid noob.

Anyway, I'm trying to make my html5 game play on IE10, but it's not detecting my clicks.

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.

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. Am I missing something or doing something incorrectly?

Please assist me.

Please forgive me in advance for being a stoopid noob.

Anyway, I'm trying to make my html5 game play on IE10, but it's not detecting my clicks.

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.

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. Am I missing something or doing something incorrectly?

Please assist me.

Share asked Jan 5, 2013 at 14:18 DonzoDonzo 1711 silver badge5 bronze badges 1
  • Do you have a link to a demo? IE does support click events, so you shouldn't need MSPointerDown. – David Storey Commented Jan 12, 2013 at 0:13
Add a ment  | 

2 Answers 2

Reset to default 9

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.

background-color:#FFFFFF; opacity:0;

For some reason, if I give the DIVS a background color and make them totally transparent, the clicks register.

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;

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.

Post a comment

comment list (0)

  1. No comments so far