将 HTML 画布作为图像复制到剪贴板
我有一个正在为客户管理的网络应用程序,该应用程序使用一个图形库,该库使用画布生成图形。客户希望用户能够复制网站中的任何图表,以便将其粘贴到Word文档中。具体问题:
是否可以将 HTML canvas 元素作为图像复制到剪贴板?
我知道可以将画布保存为图像,但它比复制/粘贴更麻烦。
编辑: 我了解到您可以将画布转换为具有数据 URI src 的图像,但对该图像的复制和粘贴支持是混合的。 Firefox 允许您从浏览器中复制并粘贴这些图像,但 Chrome 则不允许。
截至目前,似乎没有可靠的方法来复制和粘贴画布元素。
I have a web application I'm administering for a client which uses a graphing library which generates graphs using a canvas. The client wants the user to be able to copy any graph in the site so that it can be pasted into a word document. The specific question:
Is it possible to copy an HTML canvas element to the clipboard as an image?
I know that it is possible to save a canvas as an image, but it's somewhat more cumbersome than copy/paste.
EDIT:
I've learned that you can convert the canvas over to an image with a data URI src, but the copy and paste support on that image is mixed. Firefox allows you to copy and paste these images out of a browser, but chrome doesn't.
As of right now, it appears that there is not a reliable way to copy and paste a canvas element.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用 Javascript 直接与剪贴板交互,但可以在 Flash 的帮助下实现。
您可以按照建议尝试 http://code.google.com/p/zeroclipboard/这里 如何在 JavaScript 中复制到剪贴板?
复制二进制数据你可能会有问题。
另请参阅
http://danielmclaren.com/node/91
You cannot interact with clipboard directly with Javascript, but it could be possible with help of Flash.
You could try http://code.google.com/p/zeroclipboard/ as suggested here How do I copy to the clipboard in JavaScript?
Copying binary data could be problematic thou.
See also
http://danielmclaren.com/node/91