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
document.execCommand("copy");, rather withpath.select();. Strings do not have aselect()function in JS. What are you trying to accomplish with that line?