copy, cut and paste events not working in Opera
Asked Answered
C

2

0

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

$(document).ready(function(){
  $('#txtInput').bind("cut copy paste",function(e) {
      e.preventDefault();
  });
});
Cousingerman answered 27/8, 2011 at 21:59 Comment(0)
L
7

[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.

Litigious answered 27/8, 2011 at 22:11 Comment(6)
Will thy support it in the future or is there any reasons they why they not supporting that yet?Cousingerman
It will be supported in the future, just hasn't been implemented yet.Cathryncathy
@hallvors: Glad to hear it from the horse's mouth. Implementing the input event for contenteditable and the selectionchange event would be brilliant too.Woadwaxen
@TimDown: yes, we know about those events being missing too ;)Cathryncathy
For everyone reading this, the future has already happened. Opera implemented them with Presto 2.10 in April 2012Mayhew
@Mayhew Thanks for pointing that out. I updated my answer accordingly.Litigious
L
0

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();
      }
    });
Lowe answered 27/8, 2011 at 22:13 Comment(3)
is it possible to add there a line which would disable context menu call (right button click)Cousingerman
$("#element").bind("contextmenu", function(e) { e.preventDefault(); });Lowe
There's no way to stop cut, copy and paste actions from the Edit menu.Woadwaxen

© 2022 - 2024 — McMap. All rights reserved.