dev-resources.site
for different kinds of informations.
How to create COPY TO CLIPBOARD BUTTON for url of webpage
Published at
12/24/2023
Categories
css
javascript
html
immodded
Author
immodded
<button onclick="copyURL()">Copy</button>
<script>
function copyURL() {
var currentURL = window.location.href;
var tempInput = document.createElement("input");
tempInput.value = currentURL;
document.body.appendChild(tempInput);
tempInput.select();
tempInput.setSelectionRange(0, 99999);
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("Copied!")
}
</script>
Featured ones: