> For the complete documentation index, see [llms.txt](https://docs.flightwatching.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flightwatching.com/user-manual/designer-user-manual/code-snippets/download-a-file-from-a-svg-click.md).

# Download a file from a SVG click

See <https://gist.github.com/danallison/3ec9d5314788b337b682>

```javascript
      _anim.on('click', (d)=>{
        const a = window.document.createElement('a');
        a.download = `${d.ift.code}_${EVT.reg}.txt`;
        a.href = "data:application/octet-stream," + encodeURIComponent(getCD(d));
        a.dataset.downloadurl = ['text/plain', a.download, a.href].join(':');
        a.style.display = "none";
        window.document.body.appendChild(a);
        a.click();
        window.document.body.removeChild(a);
      });
```
