How to prevent click events on the document body (maybe a bug in Cordova?)

后端 未结 2 1414
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 13:24

I\'m a beginner trying to develop a mobile phone game with with Kinetic Js and \"phonegap build\". I am experiencing a problem which I don\'t know how to address. I made som

相关标签:
2条回答
  • 2021-01-04 13:36

    Have you tried this?

    stage.on('tap touchstart touchend', function() {
      return false;
    });
    

    This might help too:

    canvas {
      /*-webkit-tap-highlight-color: transparent; Some users reported this worked for them, although rgba(0,0,0,0); worked for the asker*/
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      outline: none;
    }
    

    Here is a quick link on webkit-touch-callout, I'm not sure if it will help your situation... http://phonegap-tips.com/articles/essential-phonegap-css-webkit-touch-callout.html

    EDIT: It appears the author of phone gap suggests -webkit-tap-highlight-color: rgba(0, 0, 0, 0); to prevent link selection. Source here: https://github.com/phonegap/phonegap-start/blob/master/www/css/index.css

    0 讨论(0)
  • 2021-01-04 13:44

    To disable clicking on anchor tag, you may simply use some css tricks, for example, you hav an anchor tag with class 'notclickable', then add css,

    .notclickable {
        pointer-events: none;
        cursor: default;
        opacity:0.7;
    }
    

    Now you can make an anchor tag disabled by adding this class

    or you may try this to prevent a click,

    $('.notclickable').live('click', function(event){
        event.preventDefault();
    });
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题