Created
March 5, 2021 06:25
-
-
Save sabesansathananthan/59385d6f47e11ef7992d6a07f3e8705e to your computer and use it in GitHub Desktop.
Clipboard Operation in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function copyPageUrl() { | |
try { | |
await navigator.clipboard.writeText(location.href); | |
console.log('Page URL copied to clipboard'); | |
} catch (err) { | |
console.error('Failed to copy: ', err); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment