[英]How can I copy text to the clipboard without flash in HTML5?
On Google Drive , if I try to share a file and I use Google Chrome, this button appears: 在Google云端硬盘上 ,如果我尝试共享文件并使用Google Chrome,则会显示以下按钮:
Now, if I press "copy link", it will select the textarea down the button. 现在,如果我按“复制链接”,它将选择按钮下方的textarea。 (it is a input type button) here the picture:
(这是一个输入类型按钮)这里的图片:
And the question is .... How google do to copy ad text/url to te clipboard without using flash (zeroclipboard)? 问题是....谷歌如何在不使用闪存(zeroclipboard)的情况下将广告文字/网址复制到剪贴板? which API of chrome it used?
它使用哪种铬的API? I'm try to inspect this but see only js.
我试着检查这个,但只看到js。
It is not possible to do it without flash as far as I know. 据我所知,没有闪光灯是不可能的。 However, if you are using Google Chrome and you installed the Drive App(from the webstore) then you give the browser permission to use your copy and paste.
但是,如果您使用谷歌浏览器并安装了驱动器应用程序(来自网上商店),那么您授予浏览器使用复制和粘贴的权限。
Try clicking on "right click menu" section in this article: google drive help 尝试单击本文中的“右键菜单”部分: google drive help
Basically, you need permission from the browser. 基本上,您需要浏览器的许可。 If you can't, then trick the user.
如果你不能,那就欺骗用户。 I once made a canvas which displayed text, and when the user dragged their mouse it would select the corresponding text in an invisible
<div>
, and when you press Control+C or Cmd+C you are copying the text using the native shortcut, javascript can't mimic these keys. 我曾经制作了一个显示文本的画布,当用户拖动鼠标时,它会在不可见的
<div>
选择相应的文本,当您按Control + C或Cmd + C时,您将使用本机快捷方式复制文本, javascript无法模仿这些键。
The best you can do with javascript is to select the text using document.createRange()
and leave it to the user to press Control+C or Cmd+C. 使用javascript可以做的最好的事情是使用
document.createRange()
选择文本并将其留给用户按Control + C或Cmd + C.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.