HTML5 & how to download SVG in js
how to download SVG in js
blob 7 URL
auto download
Content-Disposition: attachment; filename=yourfile.svg
// This example was created using Protovis & jQuery// Base64 provided by http://www.webtoolkit.info/javascript-base64.html// Modern web browsers have a builtin function to this as well 'btoa'function encode_as_img_and_link(){ // Add some critical information $("svg").attr({ version: '1.1' , xmlns:"http://www.w3.org/2000/svg"}); var svg = $("#chart-canvas").html(); var b64 = Base64.encode(svg); // or use btoa if supported // Works in recent Webkit(Chrome) $("body").append($("")); // Works in Firefox 3.6 and Webit and possibly any browser which supports the data-uri $("body").append($("Download"));}
canvas.toDataURL & svg
不能使用SVG图像元素作为drawImage方法的源的原因很简单,但很痛苦