1<a href="path/to/file.ext" download rel="noopener noreferrer" target="_blank">
2 Download File
3</a>
4
5<!-- Please keep in mind that the dowload attribute is not supported by IE11. This why we need a target="_blank" fallback -->
1<!--button-->
2
3<button onclick="save('NAME.html','CODE')"></button>
4
5<script>
6function save(filename, html) {
7 var el = document.createElement('a');
8 el.setAttribute('href', 'data:text/html;charset=utf-8,' + encodeURIComponent(html));
9 el.setAttribute('download', filename);
10 el.style.display = 'none';
11 document.body.appendChild(el);
12 el.click();
13 document.body.removeChild(el);
14}
15</script>
16
17<!--or-->
18<!--link-->
19<a href="the/name/of/your/file.x" download>