js能做一个选择本地文件夹目录单位东西吗,选好了文件之后返回文件路径来
2个回答
展开全部
在Windows平台上, js可以调用很多Windows提供的ActivexObject,本文就使用js来实现文档处理, 和使用js编写ActiveX做一个简单介绍.
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
展开全部
<html>
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
function writeExcel(){
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
function writeExcel(){
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |