<textarea id='input_text'
style='text-align:left; width:300px; height:60px;'>
They will be written into `demo.txt`.</textarea>
<br/><button id='write_text' style='width:306px'>
Write `demo.txt`</button>
<a download='demo.txt' id='download_text'
style='padding-left:70px; display:none'>
makeTextFile=function (text) {
var data=new Blob([text],{type:'text/plain'});
if (textFile!==null){window.URL.revokeObjectURL(textFile);}
textFile=window.URL.createObjectURL(data);
var create=document.getElementById('write_text'),
textbox=document.getElementById('input_text');
create.addEventListener('click',function(){
var link=document.getElementById('download_text');
link.href=makeTextFile(textbox.value);
link.style.display='block';},false);
No comments:
Post a Comment