Right Click Save HTML Canvas Image

时间:2015-08-14 22:56:26

标签: html google-chrome internet-explorer canvas

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

1 个答案:

答案 0 :(得分:1)

Chrome和&amp; Firefox将允许您右键单击 - save-canvas-as-image。其他浏览器没有。

这是打开画布的经典方式 - &gt;为其他浏览器创建新的浏览器标签:

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);
});