1

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboard

When I listen to a paste event in javascript, I am able to get paste data out of the clipboards as a string like so:

let pastedText: string = e.clipboardData.getData('Text');

or like so for those not using typescript:

var pastedText = e.clipboardData.getData('Text');

I am trying to re-send this event with edited clipboard data. I can re-issue the event, but I am having trouble using clipboard's setData method. I am trying this (documentation):

 e.clipboardData.setData('Text', 'lolData');

but when I run:

  console.log('NEW CLIPBOARD DATA: ');
  console.log(e.clipboardData.getData('Text'));

Nothing is printed. I don't really understand what I am doing with trying to set on the event, but it seems to make sense, since I am getting it from the event object.

VSO
  • 11,546
  • 25
  • 99
  • 187

0 Answers0