Is it possible to hack the "paste image" into the text area in Firefox?

I read this article about inserting images in Chrome and Firefox.

To reproduce, Firefox does not provide any information about the inserted image; the "paste" event handler receives a null clipboardData object.

To work, one puts the invisible div content in the DOM and always keeps it in focus, when the material is inserted, it starts a timeout that checks the contents of the invisible div to capture the image descriptor.

Is there a way to hack stuff with magic frames or is there something wrong instead of replacing textarea with a contenteditable div to get paste support in Firefox?

(note: Java and Flash solutions are out of the question)

+9
javascript firefox
Jan 04 '13 at 4:18
source share
2 answers
 <div id="paste" contenteditable="true"></div> 

Paste this element into your html, then call the following

 var pasteDiv = $("#paste")[0]; document.body.onpaste = function (event) { pasteDiv.focus(); //do your magic firefox here }; 

This is where onpaste fires because you have your contenteditable div and you can tell firefox where to focus the clipboard data. (without the presence of at least one element, the contenteditable onpaste does not work)

For a working sample, see https://gist.github.com/4577472

+3
Jan 20 '13 at 9:32
source share
— -

No. There is no other way.

* Invisible div content attributes or Java applets that run in a browser are two methods.

0
Jan 4 '13 at 5:20
source share



All Articles