I have a D3JS tree and managed to download it as an SVG file. I have used to following code to enable the download:
$(\'#download-SVG\').click(function() {