Simple JavaScript functionality OnClick event to copy a current link by clicking the image or icon and show the tooltips message saying "Link copied".
As the document.execCommand('copy'); is depreciated, its replacement is navigator.clipboard.writeText, so you can copy the current URL to clipboard with following JavaScript:
navigator.clipboard.writeText(window.location.href);
How to show the message "Link Copied" after the click?
The simple JavaScript code to show the Link Copied message after the click is:
navigator.clipboard.writeText(window.location.href);this.insertAdjacentHTML('afterend', 'Link copied');setTimeout(() => { document.querySelectorAll('.linktooltips-container').forEach(el => el.remove()); }, 3000);

How do you copy a URL on a button click?
Full code with HTML CSS and JavaScript for copying the URL on a button click is something like below, here we use SVG icon as the button:
In this way, you can copy the active URL on click, as well as please post your questions or comments, or any other easy way that you guys are using. You can follow us at our Twitter account @rupaknpl Facebook page @Webocreation. Subscribe to our YouTube channel for Opencart tutorials, and click to see other eCommerce tips and tricks.