copy, cut and paste events not working in Opera

不羁岁月 提交于 2019-12-20 07:12:16

问题


Why jquery .bind() not working in opera for cut copy paste events?

$(document).ready(function(){
  $('#txtInput').bind("cut copy paste",function(e) {
      e.preventDefault();
  });
});

回答1:


[Update] Opera implemented the Clipboard API in version 12.10 as far as I can tell, although it has been implemented in their Rendering Engine for quite some time (Presto/2.10.292).

This issue is not related to jQuery's bind function but rather to the fact that Opera didn't support cut, copy and paste events before version 12.10.




回答2:


what about alternative?

  $('#txtArea').keydown( function(e){
      if(e.which==17 || e.which == 91) isCtrl=true;
      if(isCtrl) {
        switch(e.which) {
          case 67:  dostuff(); break; //ctrl c
          case 88:  dostuff(); break; //Ctrl x
          case 86:  dostuff(); break; //ctrl 
          default:  break;
        }
        e.preventDefault();
      }
    });


来源:https://stackoverflow.com/questions/7217639/copy-cut-and-paste-events-not-working-in-opera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!