1

At some point Mozilla quietly added the ability to copy the actual (X)HTML code of a selection in Firefox to the clipboard instead of just the text content of the selection.

The question can be answered in a couple ways:

  • Is there a poorly document execCommand that prevents paste from pasting anything other than text/plain?

  • Is there a way to convert (X)HTML to text/plain during the paste event?

I am most interested in the Firefox HTML copy feature if it can be found.

I would rather not use a framework.

halfer
  • 19,824
  • 17
  • 99
  • 186
John
  • 1
  • 13
  • 98
  • 177
  • 1) Can you further explain "Mozilla queitly added the ability to copy the actual (X)HTML code of a selection" -- is this built-in, or you mean via an extension? 2) You can add [a listener for `paste` event](https://developer.mozilla.org/en-US/docs/DOM/element.onpaste) on your `input`/`textarea` but I haven't used that personally. – jakub.g Aug 11 '12 at 19:59
  • Related: http://stackoverflow.com/questions/3640187/how-can-i-modify-pasted-text – jakub.g Aug 11 '12 at 20:03
  • 1.) Text you copy in Firefox actually copies the (X)HTML code of the selection to the clipboard, not simply the textContent. 2.) That was a JavaScript question answered with jQuery. – John Aug 11 '12 at 20:12
  • Can't reproduce honestly (never happened to me). I've selected (CTRL-A) this page in Firefox 14, copied and pasted in the textarea below, or in Notepad, and it copies just text. Are you sure you don't have any add-ons that modify that? Or am I missing something? – jakub.g Aug 11 '12 at 20:53
  • Ok, looks like I don't know the literature. This is related to `contentEditable`, right? – jakub.g Aug 11 '12 at 20:59
  • 1
    Yes, contentEditable / rich text editing. – John Aug 11 '12 at 21:15

0 Answers0