jQuery 和 Canvas.toDataURL
我正在编写一个脚本,其中一小部分涉及获取画布并将其转换为可下载的图像。为此,我这样做:
var thumb_jpeg = thumbnail.toDataURL("image/jpeg");
$("#" + options.dest).attr('src',thumb_jpeg);
...其中缩略图是画布标签,选项.dest 是 img id 的名称。
这段代码在 Chrome 中完美运行,但当我在 Firefox 中尝试时,Firebug 会抛出此错误:
Security error" code: "1000
var thumb_jpeg = thumbnail.toDataURL("image/jpeg");
我会链接到整个脚本,但所有内容都托管在我的计算机上。有谁知道这可能意味着什么?
谢谢! 杰夫
I'm working on a script, and a small part of that involves taking a canvas and converting it to a downloadable image. To do this, I do:
var thumb_jpeg = thumbnail.toDataURL("image/jpeg");
$("#" + options.dest).attr('src',thumb_jpeg);
...where thumbnail is a canvas tag and options.dest is the name of an img id.
This code works perfectly in Chrome, but when I try it in Firefox, Firebug throws up this error:
Security error" code: "1000
var thumb_jpeg = thumbnail.toDataURL("image/jpeg");
I would link to the whole script, but everything is hosted on my computer. Does anyone have any idea what this might mean?
Thanks!
Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信这可能是因为您将其托管在您的计算机上。您是直接在本地文件系统上工作还是在 MAMP 或 WAMP 等本地服务器上工作?我之前曾弹出过此安全代码,当我将文件从硬盘驱动器移动到服务器时,问题得到了缓解。
I believe it may be because you have it hosted on your computer. Are you working directly from your local filesystem or are you working on a local server like MAMP or WAMP? I had this security code pop up on me before and it was alleviated when I moved my files from my hard drive on to a server.
朋友,这个方法非常有效:
Friend, this way works perfectly: