Reputation: 15489
How to get clipboard text and html without Flash in Firefox when user pressed "Ctrl+V", I can move focus into a textarea to get the paste text, or move focus to a contenteditable div to get the paste html, but how to get them both?
If I move focus to a contenteditable div to get the paste html, and then extract the text from the innerHTML, it seems that text is not exactly the same with paste event text
Upvotes: 0
Views: 2761
Reputation: 31131
Do you mean something like this demo. When you paste into the contenteditable and hit go, it'll give you both the text and HTML of what you pasted.
input = document.getElementById('a'); // is contenteditable
input.textContent; // plain text
input.innerHTML; // html
Upvotes: 1
Reputation: 20004
This has been asked before, and the answer here seems to be popular: JavaScript get clipboard data on paste event (Cross browser)
Upvotes: 1