Search code examples
javascriptjquerycssinternet-explorerpointer-events

IE10: pointer-events: none still trigger the element


I have troubles with my app in IE <=10 .

And I'm using this polyfill to support pointer-events: none in IE

but still I'm able to click my element, in other browsers I'm not.

what I'm doing wrong?

HTML:

<!DOCTYPE html>
<html>

  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <h1>Hello Plunker!</h1>

    <div class="pointed" data-pointer-events-none>ClickME!</div>
  </body>

</html>

JS:

 $(window).load(function(){
  $('.pointed').click(function(){
    alert('clicked');
  });
  PointerEventsPolyfill.initialize({});
});

and plunker:

why I still have not disabled the pointer?


Solution

  • Instead of using a polifyll you can use a simple jQuery to support IE,

    see snippet below:

    $(document).on('mousedown', '.pointed', function(e) {
      $(this).hide();
      var PointerElement = document.elementFromPoint(e.clientX, e.clientY);
      $(this).show();
      $(PointerElement).mousedown(); //Manually fire the event for desired underlying element
      return false;
    });
    .pointed {
      pointer-events: none
      /*for every non-IE browser*/
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <div class="pointed">ClickME!</div>