javascript - Save canvas as jpg to desktop -


this question has answer here:

i trying save image (jpeg) desktop html5canvas. can open in new window window.open(canvas.todataurl('png'), "");, how can save desktop? thanks.

download attribute

there new download attribute in html5 allow specify file-name links.

i made saving canvas. has link ("download image") -

<a id="downloadlnk" download="yourfilename.jpg">download image</a> 

and function:

function download() {     var dt = canvas.todataurl('image/jpeg');     this.href = dt; }; downloadlnk.addeventlistener('click', download, false); 

you can change file-name dynamically setting attribute downloadlnk.download = 'myfilename.jpg'.

demo archives.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -