FFi*_*ish 4 javascript blob canvas
我怎样才能“保存”这张图片?
blob:https%3A//theta360.com/473c6400-b8e7-4c41-8f7a-90f03cbc8787
发现于:https : //theta360.com/s/lE2in9qQDK6j2CcjPAQcvNhOi
我尝试了一些我在 SO 上找到的脚本,它使用 canvas.toDataURL
但我收到一个错误:
不允许加载本地资源:blob:https%3A//theta360.com/473c6400-b8e7-4c41-8f7a-90f03cbc8787
Javascript:
var url = "blob:https%3A//theta360.com/473c6400-b8e7-4c41-8f7a-90f03cbc8787"; // document.getElementById("img1").src; // 'img1' is the thumbnail - I had to put an id on it
var canvas = document.getElementById("MyCanvas");
var img = new Image();
img.src = url;
img.onload = function () {
var myImage = canvas.toDataURL("image/jpg");
document.getElementById("dataurl").value = myImage;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<canvas id="MyCanvas">This browser or document mode doesn't support canvas</canvas>
<input id="dataurl" name="dataurl" type="text" size="50" />
Run Code Online (Sandbox Code Playgroud)
无法请求由URL.createObjectURL()不同来源创建的 URL 。objectURL在window创建者的生命周期内存document在于创建者中。
的
URL.createObjectURL()静态方法创建一个DOMString包含代表在参数给出的对象的URL。URL 生存期与document创建它的窗口中的 . 新对象 URL 表示指定的File对象或Blob对象。