javascript - event.clipboardData is undefined -


i trying access paste event in browser , override it. event.clipboarddata undefined. have this:

function handlepaste (event) {      event.preventdefault();      console.log("handling paste");     console.log(event.clipboarddata); } 

edit:

it part of directive in angular , running in chrome:

app.directive('safepaste', [function() {  function handlepaste (event) {      event.preventdefault();      console.log("handling paste");     console.log(event.clipboarddata); }  /*  * declaration  */ var declaration = {};  declaration.restrict = 'a';  declaration.link = function(scope, element, attr) {     // attach paste handler     element.on('paste', handlepaste);      // register remove paste handler     scope.$on('$destroy', function() {         element.off('paste', handlepaste);     }); };  return declaration; }  ]); 

html:

<li ng-repeat="note in notes | reverse">      <a id="note" href="#">         <h2 id="note-title" data-note-id="{{ note.id }}" safe-paste> {{ note.title | limitto : 16 }}</h2>             <p id="note-content" data-note-id="{{ note.id }}" safe-paste> {{ note.text | limitto : 200 }} </p>             <p id="info-note-save" hidden="true" class="text-center">press enter save</p>      </a> </li> 

i had similar issue tried intercept paste event. using code here:

function handlepaste (e) {     var clipboarddata, pasteddata;      // pasted data via clipboard api     clipboarddata = e.clipboarddata || window.clipboarddata;     pasteddata = clipboarddata.getdata('text').touppercase();      if(pasteddata.indexof('e')>-1) {         //alert('found e');         e.stoppropagation();         e.preventdefault();     } }; 

i changed clipboarddata line instead

clipboarddata = event.clipboarddata || window.clipboarddata || event.originalevent.clipboarddata; 

and it's working fine.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -