Question

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!

Was it helpful?

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)">

OTHER TIPS

You can open your local file://-based page and paste the JSON object returned by calling ZeroClipboard.state(); from the browser dev console.

One can also try but may no longer be necessary: https://github.com/zeroclipboard/zeroclipboard/issues/438#issuecomment-45977023

Hope this helps!

Source: https://www.bountysource.com/issues/3786729-cannot-use-zeroclipboard-over-file-protocol

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top