我需要创建文件夹,复制它并删除。所以我创建了几个 javascript 函数 - 获取文件夹的路径、删除文件夹、创建和复制文件夹。
但是当我尝试在谷歌浏览器中运行它时,我遇到了一个异常
我认为这是 ActiveX 的问题。但在 IE 中它也不起作用。
<html>
<head>
<meta charset="utf-8">
<script type="text/javasript">
function onFolder(){
var ob = new ActiveXObject("Scripting.FileSystemObject");
var name = document.getElementById("idtextbox1").value;
var path = document.getElementById("idtextbox2").value;
var x = path + "\\" + name;
return x;
}
function onCreate(){
var ob = new ActiveXObject("Scripting.FileSystemObject");
var path = onFolder();
var x = ob.CreateFolder(path);
}
function onCopy(){
var ob = new ActiveXObject("Scripting.FileSystemObject");
var source = onFolder();
var dest = document.getElementById("idtextbox3").value;
ob.CopyFolder(source,dest + "\\");
}
function onDelete(){
var ob = new ActiveXObject("Scripting.FileSystemObject");
var folder = onFolder();
ob.DeleteFolder(folder);
}
</script>
</head>
<body>
Folder name<input type="text" id="idtextbox1">
<br>
Destination<input type="text" id="idtextbox2">
<br>
Copy destination<input type="text" id="idtextbox3">
<br>
<input type="button" id="idbutton1" value="Create" onClick="onCreate()">
<input type="button" id="idbutton2" value="Copy" onClick="onCopy()">
<input type="button" id="idbutton3" value="Delete" onClick="onDelete()">
</body>
</html>
有什么问题?是 ActiveX 吗?因为我认为javascript函数是正确的。