Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Is it possible to copy to clipboard as RTF in JS?

I want to copy text as RTF, but Clipboard API seems not to support this format according to THIS.

I wrote following function to copy the text in form of plain text (second arg) and rtf (first arg). Tried html, but doesn't work, MS Word just takes all RTF stuff as plain text.

function copy(rtf, text) {
  function listener(e) {
    e.clipboardData.setData("text/plain", text);
    e.clipboardData.setData("text/html", rtf);
    e.preventDefault();
  }
  document.addEventListener("copy", listener);
  document.execCommand("copy");
  document.removeEventListener("copy", listener);
};

I have following types:

  • text/plain
  • text/uri-list
  • text/csv
  • text/html
  • image/svg+xml
  • application/xml, text/xml
  • application/json

but there is no RTF. Is it possible to write my own type somehow?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!