<!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=gb2312" />
<title>Untitled Document</title>
</head><body>
<script language=javascript>
<!--
function ShowFolderList(folderspec)
{
   var fso, f, fc, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFolder(folderspec);
   fc = new Enumerator(f.SubFolders);
   s = "";
   for (; !fc.atEnd(); fc.moveNext())
   {
      s += fc.item();
      s += "<br>";
   }
   return(s);
}
ShowFolderList(images);
document.write(s);
//--></script>
</body>
</html>
用FireFox运行的时候为报错:ActiveXObject is not defined???  这是为什么呀??函数ShowFolderList(images)中的images文件与这个HTML文件放在同一目录下的.

解决方案 »

  1.   

    Scripting.FileSystemObject是IE的控件
      

  2.   

    写错了,是ShowFolderList(images);
    里面的 images is not defined
      

  3.   

    在IE里面也是不能运行.有没有IE和FF两都都适用的方法.
      

  4.   

    貌似这个FileSystemObject不安全,病毒就是用这个东西搞得
      

  5.   

    js浏览本地文件肯定要有的安全提示,如果坚持这么做的话,下面给各方案,首先获得磁盘: 
    function ShowDriveList()
    {   var fso, s, n, e, x;
       fso = new ActiveXObject("Scripting.FileSystemObject");
       e = new Enumerator(fso.Drives);
       s = "";
       for (; !e.atEnd(); e.moveNext())
       {
          x = e.item();
          s = s + x.DriveLetter;
          s += " - ";
          if (x.DriveType == 3)
             n = x.ShareName;
          else if (x.IsReady)
             n = x.VolumeName;
          else
             n = "[驱动器未就绪]";
          s +=   n + "<br>";
        }
       return(s);
    }
    然后再根据磁盘获得文件夹列表: 
    function ShowFolderFileList(folderspec)
    {
       var fso, f, fc, s;
       fso = new ActiveXObject("Scripting.FileSystemObject");
       f = fso.GetFolder(folderspec);
       fc = new Enumerator(f.files);
       s = "";
       for (; !fc.atEnd(); fc.moveNext())
       {
          s += fc.item();
          s += "<br>";
       }
       return(s);
    }