How Can I Share Image In Facebook In Firefox Of Using Javascript?
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 ne
Solution 1:
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
Post a Comment for "How Can I Share Image In Facebook In Firefox Of Using Javascript?"