Code:
<script>
function download(fileName, content){
var file = document.createElement('a');
file.download = fileName;
file.href = 'data:application/octet-stream,'+encodeURIComponent(content);
file.click();
}
</script>
Html:<button onclick="download('test.txt','test text.');"/>
No comments :
Post a Comment