Get html from clipboard in javascript
- by Sergey Osypchuk
I need to implement task which is quite common feature for RichTextEditors - take HTML from clipboard.
Can anyone help with guide on how to solve this task?
It has to be cross platform (IE, FF, Chrome, Opera).
I just started from this code:
<script type="text/javascript">
$('.historyText').live('input paste', function(e) {
var paste = e.clipboardData && e.clipboardData.getData ?
e.clipboardData.getData('text/plain') : // Standard
window.clipboardData && window.clipboardData.getData ?
window.clipboardData.getData('Text') : // MS
false;
alert(paste);
});</script>
Both window.clipboardData and e.clipboardData are null (Chrome, Firefox)