问题
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!
回答1:
<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)">
回答2:
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
来源:https://stackoverflow.com/questions/14821210/can-i-get-data-from-the-clipboard-with-the-new-zeroclipboard