I have implemented a function for copying to clipboard as shown below:
function CopyToClipboard(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
swal("Signature copied!","Successfully copied to clipboard.", "success");
}}
Currently, I am using an input form to update links in my project. However, the copy function does not seem to work properly after the links are updated. Here is a JavaScript example related to this issue:
$('#fbInput').on('input',function(e){
var fbInput = $('#fbInput').val();
textFB.attr("href", fbInput);
if(fbInput.length > 5 && fbInput.includes("http") !== true) { swal("Include HTTPS.","Start your URL with https://", "warning"); }
});
I would greatly appreciate any advice or solution to resolve this problem. Thank you.