4 ms·
You can copy and paste the SVG code out: <svg xmlns="http://www.w3.org/2000/svg" http://www.w3.org/2000/svg" version="1.1" width="250" height="250"><rect x="25
by ontouchstart 10y ago
You can copy and paste the SVG code out:
<svg xmlns="http://www.w3.org/2000/svg" http://www.w3.org/2000/svg" version="1.1" width="250" height="250"><rect x="25" y="25" width="200" height="200" fill="lime" stroke-width="4" stroke="pink"></rect><circle cx="125" cy="125" r="75" fill="orange"></circle><polyline points="50,125 50,200 200,200 200,125" stroke="red" stroke-width="4" fill="none"></polyline><path d="M50 125 c 25 -60 50 -60 75 0 c 25 60 50 60 75 0" fill="none" stroke-width="4" stroke="white"></path><text x="125" y="125" font-family="monospace" font-size="20" text-anchor="middle" fill="black">Hello world</text></svg>
- thadk 10y agoOr, in Chrome, use the Console.download() snippet: https://bgrins.github.io/devtools-snippets/#console-save https://bgrins.github.io/devtools-snippets/#console-save / https://github.com/bgrins/devtools-snippets/tree/master/snippets/console-save https://github.com/bgrins/devtools-snippets/tree/master/snip...
- ontouchstart 10y agoI don't think your solution works for this use case since what he wants is to save the "XML serialized" SVG element instead of a "JSON serialized" JavaScript object. A simple d3.select('svg').node().outerHTML would do the trick. (You can use the same trick as in console-save to generate a download URL though.)