直接搜索当前的所有 html 文件并div
使用超链接添加标签。它在 IE 中完美运行。但它在 Firefox 和 Chrome 中不起作用。任何人都可以帮助我......
<script type="text/javascript">
function getCurrentDirectory() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
path = unescape(document.location);
path = path.substring(8, path.lastIndexOf("/") + 1);
return path;
}
function ShowFolderFileList() {
var fso, f, f1, fc, s, temp, Extention, fileName, temp2, filePath;
folderspec = getCurrentDirectory();
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.files);
s = "";
for (; !fc.atEnd(); fc.moveNext()) {
filePath = "" + fc.item() + "";
fileName = fc.item().name;
temp = "" + fileName + ""
Extention = (temp.lastIndexOf(".") > -1) ? temp.slice(temp.lastIndexOf(".") + 1).toLowerCase() : "*";
if (Extention == "html" || Extention == "htm") {
s += "<a href=\"" + fileName + "\" target=\"_blank\">" + temp.replace("." + Extention, "") + "</a> <br>";
}
}
outPut.innerHTML = s;
}
</script>
在 html 中
<div id="outPut">
</div>
任何人都在这方面工作......