jQuery和Canvas.toDataURL [英] jQuery and Canvas.toDataURL
问题描述
我正在处理一个脚本,其中一小部分涉及到一个画布,并将其转换为可下载的图像。为此,我执行:
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);
...其中thumbnail是canvas标签,options.dest是img id的名称。
...where thumbnail is a canvas tag and options.dest is the name of an img id.
此代码在Chrome中运行得很好,但是当我在Firefox中尝试时,Firebug会抛出此错误:
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?
谢谢!
Jeff
Thanks! Jeff
推荐答案
我相信这可能是因为您将它托管在您的计算机上。你是直接从本地文件系统工作,还是在像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.
这篇关于jQuery和Canvas.toDataURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!