I need to implement a feature that copy-pastes some custom data across our websites using javascript.
After a lot of stumbling blocks, this question's lead answer pointed me in the right direction.
Basically, to copy, I add a new textarea
to my document, set its value to my desired text, and run document.execCommand('copy')
.
So far so good.
I attempting to implement paste similarly, and there lies the problem.
I add a textarea
, focus and select it, and run document.execCommand('paste')
; but it doesn't work.
Here's a fiddle demonstration:
https://jsfiddle.net/tusharx23/7zpjfh2h/1/
As you can see, the log says that 'paste was unsuccessful'
Can anyone help me get the paste to work?
Thank you.