Get html from clipboard in javascript
        Posted  
        
            by Sergey Osypchuk
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sergey Osypchuk
        
        
        
        Published on 2010-05-07T09:58:35Z
        Indexed on 
            2010/05/07
            10:08 UTC
        
        
        Read the original article
        Hit count: 264
        
JavaScript
|clipboard
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)
© Stack Overflow or respective owner