Search code examples
javascriptpastezeroclipboard

Can I GET data FROM the clipboard with the new ZeroClipboard?


I'm using this fresh version of ZeroClipboard in a project:

https://github.com/jonrohan/ZeroClipboard

Creating buttons to copy content from HTML really works like a breeze (compared to zClip or the "old" ZeroClipboard).

However I would now like to create a button which gets the current value in the clipboard and inserts it into a input field (i.e. "Click to Paste").

Unfortunately I can't find anything on that topic (getting the data from the clipboard that is - setting the value of the input ain't the issue). I'm not even sure if there is another solution other than using ZeroClipboard.

Any help is greatly appreciated!


Solution

  •     <script type="text/javascript">
            function getClicpboardData(Event){
    
                alert(window.clipboardData.getData('Text')); //if IE
    
                // alert(Event.clipboardData.getData('text/plain')); 
    
    
            }
        </script>
        <input type="submit" value="pasteClipboardData" onclick="getClicpboardData(event)">