7

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!

user1673579
  • 134
  • 7
  • 3
    For security reasons, this is not possible. – SLaks Feb 11 '13 at 21:33
  • What @SLaks said. From [Adobe docs](http://help.adobe.com/en_US/as3/dev/WS2F6A31B9-1AE6-4b23-9C12-57A33F4F0516.html): Content running in Flash Player or in a non-application sandbox in AIR can call the getData() method **only in an event handler for a paste event**. – andytuba Feb 11 '13 at 21:57
  • Thanks for the quick clarification. – user1673579 Feb 12 '13 at 21:20
  • In addition the the previous comments, except in rare circumstances (for example, the File API), JavaScript does not have access to a machine outside of the DOM, for security reasons. – Matthew Herbst Sep 15 '14 at 17:11
  • No unless you use a browser plugin – stevemao Nov 13 '14 at 06:36

2 Answers2

0

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

Kevin Austin
  • 184
  • 7
0
    <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)">
  • You should add some comments around the code you post as answer, because it is not clear. Does this code really use ZeroClipboard as requested by the author in his question? – Antwane Nov 28 '14 at 13:47
  • no i just gave to get data from clipboard,because he mentioned like is there any other way to get recent clipboard data. – jiten patel Dec 01 '14 at 05:00