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

半城伤御伤魂 提交于 2020-01-14 07:47:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!