JavaScript 将文本复制到剪贴板
这个让我坚持了很长一段时间。如何将文本复制到剪贴板?这是我的代码:
<body>
<textarea name="text" rows="5" cols="20" wrap="hard" onblur="CopyToClipboard()">Enter text here and it will be copied to the clipboard!</textarea>
</body>
<script type="text/javascript">
function CopyToClipboard() {
//O_O Confused... what do I do...
}
</script>
Possible Duplicate:
Copy selected text to the clipboard WITHOUT using flash - must be cross-browser
This one has kept me going for a long time. How would I copy text to the clipboard? Here is my code:
<body>
<textarea name="text" rows="5" cols="20" wrap="hard" onblur="CopyToClipboard()">Enter text here and it will be copied to the clipboard!</textarea>
</body>
<script type="text/javascript">
function CopyToClipboard() {
//O_O Confused... what do I do...
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法...
这只适用于 IE 4 及更高版本。当您运行它时,可能会出现一个对话框,询问您是否“您希望该网站访问您的剪贴板”。如果是,请单击“是”。用户在框中输入的任何文本都将被复制到剪贴板。
Here is one way you can do it...
This only works with IE 4 and above. When you run it, a dialog may come up asking you whether or not "you want this website to have access to your clipboard". Click yes if it does. Whatever text the user entered into the box will be copied to the clipboard.