xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<title>Copy Text from HTML</title>
</head>
<body>
<div id="textToCopy">This is the text to copy</div>
<button onclick="copyText()">Copy Text</button>
<script>
function copyText() {
const textToCopy = document.getElementById("textToCopy");
const text = textToCopy.innerText || textToCopy.textContent;
navigator.clipboard.writeText(text)
.then(() => {
console.log("Text copied to clipboard!");
})
.catch((error) => {
console.error("Error copying text:", error);
});
}
</script>
</body>
</html>
xxxxxxxxxx
<script type="text/JavaScript">
//courtesy of BoogieJack.com
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>
xxxxxxxxxx
<a class="cls_copy_pg_action copyAction copy-action-btn" data-value="THIS TEXT WILL BE COPIED"> <i class="far fa-copy"></i> Copy</a>
xxxxxxxxxx
<div class="CopyMeClass" id="CopyMeID">The text to copy to the clipboard.</div>
<div><button onclick="CopyClassText()">Copy The Text</button></div>