<title>pubs</title>
<style>
&nb">

jscript读写TEXT文件示例

80酷酷网    80kuku.com

  js|jscript|示例<html>
<head>
<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>
</head>
<script language="javascript">
 var path="c:\\";
 var fname="everyone.txt"
 window.status="公告栏";
 function getFname(){
  if (txt1.value != "" && txt1.value != " "){
   fname=txt1.value;
  }
 }
 function savefile(){
  var fso,file;
  if (tbox1.value == ""){
   alert("请输入您想要公告的信息,再存储!");
   return;
  }else{
   getFname();
   fso=new ActiveXObject("Scripting.FileSystemObject");
   file = fso.CreateTextFile(path + fname,true);
   file.WriteLine(tbox1.value);
   file.close();
   alert("完成!");
  }
 }
 function readfile(){
  var fso,str,file;
  getFname();
  fso = new ActiveXObject("Scripting.FileSystemObject");
  str = "没有您的留言";
  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="28">E-Mail:
      <input type="text" id="txt1">
   <button name="save" >存储</button>
   <button name="read" >阅读</button>
    </td>
  </tr>
  <tr>
    <td height="23"><div align="center">公告内容</div></td>
  </tr>
  <tr>
    <td><textarea name="tbox1" rows="18" cols="60"></textarea></td>
  </tr>
</table>
</body>
</html>



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: