-1

The following code works in Chrome (outputs to the log and does other processing). However in IE10 the function is not called. Nothing displayed in console in IE 10 and there are no errors on the page reported by Chrome or IE10.

I checked other questions and one item which comes up is that the code is known to fail if the link is disabled, but my link is not disabled! in fact the link click works fine, only the funciton is not being called.

  $('a').click(function (e) {

                 console.log('click event detected with button '+e.which);
                 if (e.which == 2) {
                     e.preventDefault();
                   ...
                 }
shelbypereira
  • 2,097
  • 3
  • 27
  • 50

2 Answers2

0

You can try this:

<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script type="text/javascript" src="jquery-1.10.2.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $(document).on('click','a',function (e) {
                console.log('click event detected with button '+e.which);
        if (e.which == 2) {
        e.preventDefault();
        }
        });
        });
        </script>
    </head>
    <a href="#">hello</a>
    <body>

    </body>
</html>

Hope it'll work for you

Jack
  • 163
  • 1
  • 15
  • I tride this, and it fails also. I think there might be a setting enforced by policy which is forcing some compatibility or disabling the override of the click. I tried adding this to the header: as indicated here in another situation: http://stackoverflow.com/questions/25557299/internet-explorer-11-disable-display-intranet-sites-in-compatibility-view-via but even this fails. – shelbypereira Apr 09 '15 at 08:43
-2

How about using CSS seletor?

$("#a").click(....);