Example of a JScript read-write text file

Source: Internet
Author: User
js|jscript| Example <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>pubs</title>
<style>
Table {
Border:2 Groove Blue;
Position:absolute;
top:100;
left:300;
}
TD {
Border:1 Ridge Green;
}

</style>
<script language= "JavaScript" >
var path= "c:\\";
var fname= "Everyone.txt"
window.status= "bulletin boards";
function Getfname () {
if (Txt1.value!= "" && txt1.value!= "") {
Fname=txt1.value;
}
}
function SaveFile () {
var fso,file;
if (Tbox1.value = = "") {
Alert ("Please enter the information you want to post, then store!");
Return
}else{
Getfname ();
Fso=new ActiveXObject ("Scripting.FileSystemObject");
FILE = fso. CreateTextFile (path + fname,true);
File. WriteLine (Tbox1.value);
File.close ();
Alert ("Complete!");
}
}
function ReadFile () {
var fso,str,file;
Getfname ();
FSO = new ActiveXObject ("Scripting.FileSystemObject");
str = "No message for You";
if (FSO). FileExists (path + fname)) {
File=fso. OpenTextFile (path + fname,1);
Str=file.readall ();
File.close ();
}
Tbox1.value = str;
}

</script>
<body>
<table width= "437" height= "157" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<TD width= "433" height= ">e-mail":
<input type= "text" id= "Txt1" >
<button name= "Save" > Storage </button>
<button name= "read" > Reading </button>
</td>
</tr>
<tr>
<TD height= "><div" align= "center" > Announcement Content </div></td>
</tr>
<tr>
<td><textarea name= "Tbox1" rows= "cols=" ></textarea></td>
</tr>
</table>
</body>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.