Detect the Content Type in the Clipboard

A user’s clipboard is a “catch all” between the operating system and the apps employed on it. When you use a web browser, you can highlight text or right-click an image and select “Copy Image”. That made me think about how developers can detect what is in the clipboard. You can retrieve the contents of the user’s clipboard using the navigator.clipboard API. This API requires user permission as the clipboard could contain sensitive data. You can employ the following JavaScript to get permission to use the clipboard API: const result = await navigator.permissions.query({name: "clipboard-write"}); if (result.state === "granted" || result.state === "prompt") {... more →
Posted in: JavaScript

Roll Your Own Copy to Clipboard Feature in 20 Lines of JavaScript – SitePoint

Roll Your Own Copy to Clipboard Feature in 20 Lines of JavaScriptSitePointUsing the OS clipboard is a basic IT skill. As a developer, you've learned that tab, Ctrl/Cmd+A, Ctrl/Cmd+C followed by Ctrl/Cmd+V will highlight, copy and paste in an instant. Life is less easy for regular users. Even if a user knows what the … JavaScript – Google News… more →
Posted in: JavaScript