Copy to Clipboard HTML

I want to copy an HTML string to the Clipboard. In the appstore there is an widget called 'ClipboardTextCopy' that can be used to copy plain text and from github I got the widget 'CopyURL', but again it is only possible the copy plain text. I looked on the internet and found that it is possible to add a tag specifying that it is a HTML string. Like this:  window.clipboardData.setData("text", "<div>Testing</div>");   window.clipboardData.setData("html", "<div>Testing</div>");   Can anyone point me to a widget that has the option to copy HTML or how to change one of the above widget adding this tag?   Regards, Peter
1 answers

Hi Peter,

NOTE: Microsoft says that function is deprecated in Edge, and support for the function is a bit unclear.

If you're willing to get your hands dirty with JavaScript, you can certainly modify one of these widgets for your needs. Here are 2 links to get you going:


Assuming you use ClipboardTextCopy as your base, you'd probably make these changes:

  • Add a new enumeration property to the widget's XML file, call it "dataType" with 2 options: "text" and "html". Within the scope of the main widget functions, you can access this property using "this.dataType"
  • Edit this line to use your new function


Good luck!