0

I'm trying to build a WYSIWYG, and I've three buttons: copy, cut and paste.

I tried this script for each one of them, but it didn't worked.

This is my script :

//Copy
document.getElementById('copy').addEventListener('click', function(){
    document.execCommand('copy', false, null);
}, false);

//Cut
document.getElementById('cut').addEventListener('click', function(){
    document.execCommand('cut', false, null);
}, false);

//Paste
document.getElementById('paste').addEventListener('click', function(){
    document.execCommand('paste', false, null);
}, false);

In Google chrome, Internet Explorer 11, Safari and Opera no one of them has worked, and I don't get anything in the console.

In Mozilla Firefox I get this message :

Error: Permission denied for <file://> to get property Clipboard.cutcopy
document.execCommand('cut', false, null);

The same thing for copy and paste.

How can I solve this ?

Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191

1 Answers1

0

You cannot do this with JavaScript alone. You you have to depend on flash for this. Checkout zeroclipboard. It might shed some hope :)

redV
  • 684
  • 1
  • 9
  • 26
  • You can most definitely do this **without** flash in many modern browsers. – qwertynl Feb 28 '14 at 18:43
  • Could you please list some `modern browsers`? Even I am curious to know how would it be possible without permissions. – redV Feb 28 '14 at 18:47