저는 JavaScript가 처음이므로이 질문에 대한 대답이 분명한 경우 저를 용서하십시오.HTML5와 JavaScript를 사용하여 일반 텍스트 파일 가져 오기
텍스트 편집기 웹 응용 프로그램의 가져 오기 기능을 설정하려고합니다.
function dataImport() {
confirm("Are you sure you want to import the selected file? This will overwrite any data that is currently saved in the application workplace.");
var fileReader = new FileReader();
window.localStorage.setItem("AppData", fileReader.readAsText(document.querySelector("#import-selector").value));
};
를 그리고이 활성화되어야한다 : 다음과 같이
내 코드가 대신 로컬 스토리지에 파일의 내용을 작성하는
<input id="import-selector" type="file" /><button id="import-button" onclick="dataImport();">Import File</button>
, 그러나, 단순히 단어를 쓴다 '정의되지 않음'. 나는 어떤 종류의 오류가 발생했다고 생각하지만, 나는 그것이 무엇인지 모른다.
도움이나 조언을 미리 보내 주셔서 감사합니다.
어떤 브라우저를 사용하고 있습니까? –
Google 크롬, 개발자 채널. –