问题
Is there a way to save to the local filesystem a canvas with loaded images from external websites into it?
If I try with toDataUrl(), it just trhows a Security error. In Firefox I can just save to a file the canvas with the right click, but this is not possible in Chrome.
回答1:
No, for security reasons you can't use toDataUrl().
For why this is happening you need to look into cors.
Here's a bit on why it should be this way.
It's a feature in Firefox that you can right-click save-as because its all local. If it were with toDataUrl() then the webpage could also attempt to send the canvas data to the server and we don't want that.
The right-click save-as is a requested feature in Opera and may come to other browsers someday but I wouldn't bank on the functionality existing any time soon.
来源:https://stackoverflow.com/questions/9656521/save-canvas-with-external-images-to-local-file