Answer the question
In order to leave comments, you need to log in
How to copy text to clipboard from popup.js chrome extension clipboard?
https://jsbin.com/mayenevubi/edit?html , js tried
this way but throws Discontiguous selection is not supported.
here is the manifest
"permissions": [
"webNavigation",
"notifications",
"tabs",
"storage",
"clipboardRead",
"clipboardWrite"
],
Answer the question
In order to leave comments, you need to log in
<textarea class="js-copytextarea">Hello I'm so11111me text</textarea>
var copyTextareaBtn = document.querySelector('.js-textareacopybtn');
copyTextareaBtn.addEventListener('click', function(event) {
var copyTextarea = document.querySelector('.js-copytextarea');
copyTextarea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question