问题描述
var image = canvas.toDataURL(image / png);
现在我想在Facebook上分享。如何使用javascript来做firefox os。
我很新。我搜索很多但不幸的是我没有得到任何结果。
分享您的图片建议使用WebActivities,允许您与其他应用程序交互,例如,共享图片或文本...
下面我留下一个简单的代码实现它并分享你的图像,你必须指定它是一个图像,并将其作为一个blob传递。 p>
blobCanvas.width = imgToShare.width;
blobCanvas.height = imgToShare.height;
//获取上下文并绘制图像
var blobCanvasContext = blobCanvas.getContext(2d);
blobCanvasContext.drawImage(imgToShare,0,0);
//导出到blob并通过Web共享Activitiy
blobCanvas.toBlob(function(blob){
new MozActivity({
name:share
data:{
type:image / *,
number:1,
blobs:[blob]
}
});
});
我建议您阅读有关
I have an image generated from canvas.
var image = canvas.toDataURL("image/png");
Now I want to share it in facebook. How can I do it for firefox os using javascript.I am very new. I search a lot but unfortunately I did not get any results.
To share your image is recommended to use the WebActivities allowing you to interact with other applications, for example, share a picture or text ...
Below I leave a simple code to implement it and share your image, you must specify that it is an image and pass it as a blob.
blobCanvas.width = imgToShare.width;
blobCanvas.height = imgToShare.height;
// Get context and draw image
var blobCanvasContext = blobCanvas.getContext("2d");
blobCanvasContext.drawImage(imgToShare, 0, 0);
// Export to blob and share through a Web Activitiy
blobCanvas.toBlob(function (blob) {
new MozActivity({
name: "share",
data: {
type: "image/*",
number: 1,
blobs: [blob]
}
});
});
I recommend you read more about WebActivities in the MDN
这篇关于如何在Firefox中使用javascript分享图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!