javascript code to save a txt file

后端 未结 6 1117
走了就别回头了
走了就别回头了 2021-01-06 12:50

can any body tell me how i create a .txt file using javascript which is browser compatable too.

and after creating the file it gives the save as diaglog box so that

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 13:41

    If you're looking for IE only solution, try this:

    function createFile() {
        set fso = new ActiveXObject("Scripting.FileSystemObject");
        set s = fso.CreateTextFile("C:\test.txt", True);
        s.writeline("HI");
        s.writeline("Bye");
        s.writeline("-----------------------------");
        s.Close();
    }
    

提交回复
热议问题