我可以制作一个书签,将一些文本放入剪贴板吗?
假设我想要一些文本(实际上是 4 个不同的地址),我希望能够轻松(并且经常)粘贴它们。有没有办法制作一个书签,将这些地址放入剪贴板? 我希望能够单击相应的选项,然后右键单击 + 粘贴。
Say I wanted to have bit of text (actually 4 different addresses) that I'd like to be able to easily (and frequently) paste. Is there a way I can make a bookmarklet that will put those addresses into the clipboard?
I'd like to be able to click the appropriate one, then right click + Paste.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是可能的,请查看 zeroclipboard(注意:需要 Flash)。另请参阅上一个问题。
Yes it's possible, have a look at zeroclipboard (note: requires flash). Also see this previous question.
尝试构建 Firefox 扩展而不是小书签。 Mozilla XUL(扩展语言)允许您进行复制粘贴。另一种选择是 Java Applet。
http://brooknovak.wordpress.com/ 2009/07/28/使用javascript访问系统剪贴板/
Try building a Firefox extension instead of a bookmarklet. Mozilla XUL (extension language) lets you do copy-paste. Another option is a Java Applet.
http://brooknovak.wordpress.com/2009/07/28/accessing-the-system-clipboard-with-javascript/
没有第三方库的方法
虽然 Zeroclipboard 可能有效,但此方法将允许您直观地选择一个元素并自动将内部文本复制到剪贴板,无需下载任何第三方库。它基于 该函数由 Arne Hartherz 开发并修改为在 HTTPS 和 HTTP 上下文中都可以工作。
可读版本:
用于书签的缩小版本:
Method with no third-party libraries
While zeroclipboard could potentially work, this method will allow you to visually select an element and automatically copy the inner text to your clipboard without having to download any third-party libraries. It is based on this function by Arne Hartherz and modified to work both in HTTPS and HTTP contexts.
Readable version:
Minified version for use in bookmarklet: