'Problem with Document.execCommand("copy")
I am having a problem when copying values. I use Clipboard API but know Clipboard API only works with secure context (HTTPS), in my Beta it's only HTTP so Clipboard API doesn't work. So is there a way to use document.execCommand("copy") in this case? I can simulate my code that is having problems as follows:
let path = 'https://google.com'
if(navigator.clipboard) {
navigator.clipboard.writeText(path).then(function() {
console.log("Success!")
}, function() {
console.log("Failed!")
});
} else {
// Using document.execCommand("copy")
path.select();
document.execCommand("copy");
}
And the problem I have is:
Uncaught TypeError: path.select is not a function
Can someone help me with the use case of document.execCommand("copy")? Thanks very much
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
