document.addEventListener('DOMContentLoaded', function () { const copyLinkBtn = document.getElementById('copyLinkBtn'); const facebookShareBtn = document.getElementById('facebookShareBtn'); const xShareBtn = document.getElementById('xShareBtn'); const pageUrl = window.location.href; // Copy Link Functionality copyLinkBtn.addEventListener('click', function () { navigator.clipboard.writeText(pageUrl).then(() => { alert('Link copied to clipboard!'); }).catch(err => { alert('Failed to copy the link.'); }); }); // Facebook Share Functionality facebookShareBtn.addEventListener('click', function () { const facebookShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(pageUrl)}`; window.open(facebookShareUrl, '_blank', 'width=600,height=400'); }); // X (formerly Twitter) Share Functionality xShareBtn.addEventListener('click', function () { const text = encodeURIComponent("Check out this blog post!"); const xShareUrl = `https://x.com/intent/tweet?url=${encodeURIComponent(pageUrl)}&text=${text}`; window.open(xShareUrl, '_blank', 'width=600,height=400'); }); });