JavaScript读写脚txt文件
1.cmd切换到“C:\Windows\System32>”下,执行“regsvr32 Scrrun.dll”
2.JavaScript读写txt文本代码如下,注意要发布到服务器上
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>读写txt文件</title>
</head>
<body>
<script>
function writeFile(filename,filecontent)
{
var fso, f, s ;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,8,true);
f.WriteLine(filecontent);
f.Close();
alert('写入txt数据成功!');
}
//读文件
function readFile(filename){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(filename,1);
var s = "";
while (!f.AtEndOfStream)
s += f.ReadLine()+"/n";
f.Close();
return s;
}
</script>
<input type="text" id="txtwrite" value="helloworld">
<input type="button" value="Write!" onclick="writeFile('c://a.txt',document.getElementById('txtwrite').value)"/>
<input type="button" value="Read!" onclick="document.getElementById('show').value=readFile('c:/a.txt')"/>
<br>
<textarea id="show" name="show" cols="30" rows="4" ></textarea>
</body>
</html>
JavaScript读写脚txt文件的更多相关文章
- 用PHP的fopen函数读写robots.txt文件
以前介绍了用PHP读写文本文档制作最简单的访问计数器不需要数据库,仅仅用文本文档就可以实现网页访问计数功能.同样我们可以拓展一下这个思路,robots.txt文件对于我们网站来说非常重要,有时候我们需 ...
- javascript操作写入txt文件及消息: Automation 服务器不能创建对象问题
简单的写入txt代码: function WriteTxt() { var fso, tf; fso = new ActiveXObject("Scripting.Fil ...
- 读写文本(.txt)文件 .NET
http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...
- Javascript写入txt和读取txt文件的方法
文章主要介绍了Javascript写入txt和读取txt文件的方法,需要的朋友可以参考下1. 写入 FileSystemObject可以将文件翻译成文件流. 第一步: 例: 复制代码 代码如下: Va ...
- [转载]C#读写txt文件的两种方法介绍
C#读写txt文件的两种方法介绍 by 大龙哥 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char ...
- Java逐行读写TXT文件
package help; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; imp ...
- c# txt文件的读写
在公司实习,任务不太重,总结一下c#关于txt文件的读写,以便以后有用到的时候可以查看一下.如果有写得不完整的地方还请补充 说明:本人C#水平可能初级都谈不上,高手轻喷,参考:http://www.c ...
- python 简单的txt文件读写
1 读取txt文件.跟c相比,python的文件读写简直是方便的可怕 首先是读取文件 首先获得文件名称,然后通过 open函数打开文件,通过for循环逐行读出文件内容 #!python file by ...
- Java读写txt文件
1.Java读取txt文件 1.1.使用FileInputStream: public static String readFile(File file, String charset){ //设置默 ...
随机推荐
- 【php学习】字符串操作
关于字符串的处理,基本上就是那几种操作:字符串长度.查找子字符串的位置.替换字符串.截取字符串.拆分合并字符串 ... 字符串的定义:直接 $str = "abcd"; 或者 $s ...
- epoll 应用
/* * test_bittube.cpp * * Created on: 2015年7月13日 * Author: ting.guit */ #include <bind ...
- 【转】get a mysterious problem,when i use HttpWebRequest in unity c# script
in script,i use HttpWebRequest to get service from network.but it comes a mysterious problem. the so ...
- Mongo中的数据类型
一.null null用于表示空值或者不存在的字段 {"X" : null} 二.布尔型 布尔类型有两个值true和false {"x" : true} 三.数 ...
- How to Move Magento to a New Server or Domain
Magento is one of the fastest growing eCommerce platforms on the internet and with its recent acquis ...
- [LeetCode]题解(python):80-Remove Duplicates from Sorted Array II
题目来源 https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ Follow up for "Remov ...
- magento csv导入
- js判断是否为空火undefined是否给undefined加引号
js判断是否为空为undefined如果判断的是类型则用typeof(),如果其本身就是“undefind”字符窜,则不能这样判断, 这样typeof之后是字符串类型就判断不出来了,这是需要去掉typ ...
- Codeforce727B --- Bill Total Value(字符串处理 正则表达式)
先说一下正则表达式 %*[a-z]表示忽略前面的小写字符,%[0-9]表示把紧接着非字符的连续数字存入t字符串中去; 从"abc123de4f"中得到"123" ...
- Asset Store
Asset Store 是用来供Unity开发者将自己的插件拿出来供大家有偿使用的一个平台. 报错信息: failed to import package with error cannot impo ...