//var dataURL = canvas.toDataURL();
//document.getElementById("canvasimg").src = dataURL;
//var dt = canvas.toDataURL('image/png');
- var dt = canvas.toDataURL();
+ //var dt = canvas.toDataURL();
/* Change MIME type to trick the browser to downlaod the file instead of displaying it */
- dt = dt.replace(/^data:image\/[^;]*/, 'data:application/octet-stream');
+ //dt = dt.replace(/^data:image\/[^;]*/, 'data:application/octet-stream');
/* In addition to <a>'s "download" attribute, you can define HTTP-style headers */
- dt = dt.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=Canvas.png');
- this.href = dt;
+ //dt = dt.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=Canvas.png');
+ //this.href = dt;
+ var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // here is the most important part because if you dont replace you will get a DOM 18 exception.
+ window.location.href=image; // it will save locally
}