Tom Buxton
Tom Buxton

Reputation: 65

Right Click Save HTML Canvas Image

Right clicking and saving image as is simple in google chrome as the canvas is treated like an <Img> element. But it almost any other browser when you right click on a canvas it doesn't give you the option to save. How do I get around this I need a way the user can save a canvas on a page, or how do I allow the right click and save image as option in browsers like IE.

Thanks

Upvotes: 1

Views: 2906

Answers (1)

markE
markE

Reputation: 105015

Both Chrome & Firefox will let you right-click-save-canvas-as-image. Other browsers don't.

Here's a classic way of opening up a canvas-->image new browser tab for other browsers:

mySaveButton.addEventListener('click', function(ev) {
    var html="<p>Right-click on image below and Save-Picture-As</p>";
    html+="<img src='"+canvas.toDataURL()+"' alt='from canvas'/>";
    var tab=window.open();
    tab.document.write(html);
});

Upvotes: 1

Related Questions