Add id "copyURL" to button
JavaScript
<script>
const copyBtn = document.getElementById('copyURL');
/*!
* © This code was written by Aditya Yadav.
* For more information, visit my Youtube channel:https://www.youtube.com/@CreateDreamWebsite
*/
copyBtn.addEventListener('click', () => {
const url = window.location.href;
navigator.clipboard.writeText(url).then(() => {
alert('URL copied successfully!');
}).catch(() => {
alert('Error copying URL to clipboard');
});
});
</script>