Asked by duncanb7
at 2024-06-02 14:01:49
Point:250 Replies:6 POST_ID:828306USER_ID:11059
Topic:
JavaScript;;Hypertext Markup Language (HTML)
Dear Expert,
I would like to create, write, read, delete a file by Javascript in HTMl, and I got the following Expert's code
(The deleting part is missing), Please see the attached code
From IE output result, I've seen "Hello World" in message box by alert() in read_from_file() function
Question-1:the function of write_to_file code part is seeming working otherwise I could not see the alert message but I could not find out the textfile.txt in my active current dir on my PC, it is really strangeeven I searched
whole PC dir, I could not find it.
Question-2, Where I can find out the delete part code and Javascript reference manual so I could find out
the 1, 2 meaning in openfile = axo.OpenTextFile("testfile.txt", 1)?
Question-3, Do you have any Javescript debugger recommandation for purchase or trial downlaod ?
Question-4, What is "new" mean in the code: make = new ActiveXObject("Scripting.FileSystemObject") ?
Best Regards
Duncan
Attached
I would like to create, write, read, delete a file by Javascript in HTMl, and I got the following Expert's code
(The deleting part is missing), Please see the attached code
From IE output result, I've seen "Hello World" in message box by alert() in read_from_file() function
Question-1:the function of write_to_file code part is seeming working otherwise I could not see the alert message but I could not find out the textfile.txt in my active current dir on my PC, it is really strangeeven I searched
whole PC dir, I could not find it.
Question-2, Where I can find out the delete part code and Javascript reference manual so I could find out
the 1, 2 meaning in openfile = axo.OpenTextFile("testfile.txt", 1)?
Question-3, Do you have any Javescript debugger recommandation for purchase or trial downlaod ?
Question-4, What is "new" mean in the code: make = new ActiveXObject("Scripting.FileSystemObject") ?
Best Regards
Duncan
Attached
<HTML>
<HEAD>
<TITLE>Create a file by JavaScript</TITLE>
</HEAD>
<BODY>
<script type="text/javascript" >
function make_file() {
make = new ActiveXObject("Scripting.FileSystemObject")
make.CreateTextFile("testfile.txt")
}
function read_from_file() {
axo = new ActiveXObject("Scripting.FileSystemObject")
openfile = axo.OpenTextFile("testfile.txt", 1)
var value = openfile.ReadLine()
openfile.Close()
alert(value)
}
function write_to_file(some_text) {
axo = new ActiveXObject("Scripting.FileSystemObject")
openfile = axo.OpenTextFile("testfile.txt", 2)
openfile.Write(some_text)
openfile.Close()
}
make_file()
write_to_file('hello world')
read_from_file()
</script>
</body>
</html>