Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
How to create a file by Javescript in HTML

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>
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm
You will get a permission denied on most if not all requests using the above methods with current browsers and security measures.
This might would be allowed only using IE and with least security settings which probably no one would be using, imagine what would have happened if a web page was able to create or delete files from your hard drive.
JavaScript is a client-server scripting, which also will limit it from creating files on the server, so you will either need to use a server-scripting language such as ASP.NET, PHP, CGI etc.. or you can use Javascript to do an ajax-request that calls a server-side script to do it for you on the server.
However, this being said, this link shows all possible file operations using JavaScript
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
This one also shows how to delete
http://www.java2s.com/Tutorial/JavaScript/0600__MS-JScript/FileDelete.htm