function writeFile(fileName, text) {
var blob = new Blob([text], { type: 'text/plain' });

objURL = window.URL.createObjectURL(blob);

if (window.__Xr_objURL_forCreatingFile__) {
window.URL.revokeObjectURL(window.__Xr_objURL_forCreatingFile__);
}
window.__Xr_objURL_forCreatingFile__ = objURL;

var a = document.createElement('a');

a.download = fileName;
a.href = objURL;
a.click();
}

'Web' 카테고리의 다른 글

[javascript] 로컬 파일 불러오기 (chrome)  (0) 2019.07.31

xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : alert("use chrome");

xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) {

document.getElementById("id").innerHTML=xmlhttp.responseText;

}

}

xmlhttp.open("GET","test.txt",true);

xmlhttp.send();

'Web' 카테고리의 다른 글

[js] .txt 파일 로컬 저장  (0) 2019.07.31

+ Recent posts