简体   繁体   English

如何单击元素并使用javascripts“ copy”事件添加到剪贴板

[英]How to click on an element and use javascripts “copy” event to add to the clipboard

Javascript finally has the "copy" event and we no longer have to use flash! JavaScript终于有了“复制”事件,我们不再需要使用flash! (well, we still should use flash as a fallback). (嗯,我们仍然应该使用flash作为后备)。

http://dev.w3.org/2006/webapi/clipops/#x3.1.1-copy-event http://dev.w3.org/2006/webapi/clipops/#x3.1.1-copy-event

I'm trying to figure out how to: Click on an anchor tag (Copy) and it copies the (text input src /or innerHTML) to the clipboard. 我试图弄清楚如何:单击定位标记(复制),然后将(文本输入src /或innerHTML)复制到剪贴板。 Here's a fiddle of the HTML/CSS http://jsfiddle.net/LkUhM/ 这是HTML / CSS的小提琴http://jsfiddle.net/LkUhM/

Can anyone guide me? 谁能指导我?

:::::HTML::::: ::::: HTML :::::

<div>
<ul>
    <li><input type="text" class="input" value="This is the next that will be copied!" /><a href="#" id="copy" class="copy">Copy!</a></li>
    <li><input type="text" class="input" value="This is the next that will be copied!" /><a href="#" id="copy" class="copy">Copy!</a></li>
    <li><input type="text" class="input" value="This is the next that will be copied!" /><a href="#" id="copy" class="copy">Copy!</a></li>
    <li><input type="text" class="input" value="This is the next that will be copied!" /><a href="#" id="copy" class="copy">Copy!</a></li>
</ul>

<textarea></textarea>

  1. You're looking at an old version of that spec. 您正在查看该规范的旧版本。 The new one is here: http://www.w3.org/TR/clipboard-apis/ 新的是在这里: http : //www.w3.org/TR/clipboard-apis/
  2. According to the current spec, you cannot programmatically simulate any of these clipboard events. 根据当前规范,您不能以编程方式模拟任何这些剪贴板事件。 I am trying to work with the appropriate W3C working group to get that changed to at least allow simulation when the user clicks and/or issues a keyboard event (just like how you can get write access to the clipboard with Flash). 我正在尝试与适当的W3C工作组合作,以将其更改为至少在用户单击和/或发出键盘事件时允许模拟(就像您可以通过Flash获得对剪贴板的写权限一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM