简体   繁体   中英

Cannot Export Canvas as Image

I have single html page on this page I am just trying to download the canvas but getting this

在此处输入图片说明 , I have also tried this but no luck ,also I cannot set CORS policy because there no web framework behind

$("#download" ).click(function() {
console.log( "Handler for .click() called." );

var link = document.createElement('a');
link.download = 'image.bmp';
link.href = document.getElementById('myCanvas').toDataURL();
link.click();

});

I think this is because you are loading this on the file protocol.

Try running it on an http-server, if you haven't got anything set-up, give the npm http-server package a try. Shouldn't take you more than 5 mins to set it up.

just install it globally and then run your folder.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM