How to create a "copy text to clipboard" button?

Hi there!

I have been trying to look for a solution to include a button on one of my WordPress posts which would copy a certain text into the clipboard when clicked. I however am no developer and haven’t found any good plugin for this (or I seem to be bad at searching).

Anyone has a clue on how to do this?

And for a reason.

The clipboard belongs to the user and for security reasons access to it needs to be initiated by the user, not script.

For example, depending on the browser used, if a user selects some text, that indicates that the user has “allowed” access to their clipboard. At that point, in addition to the browsers context menu JavaScript might then be able to display a type of “copy to clipboard” button.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.