以下这个JS脚本,共参考。此例是搜索“C:\My   Documents”中的所有HTML文件  
  <script>  
  function   HTMlist(path){  
  var   txt;  
  fso   =   new   ActiveXObject("Scripting.FileSystemObject");  
  fldr   =   fso.GetFolder(path);  
  fc   =   new   Enumerator(fldr.files);  
  for   (;   !fc.atEnd();   fc.moveNext())   //枚举所有文件  
  {  
          s=fc.item();   //取文件对象  
           
          if   (s.type=="HTML   Document"){   //判断是否是“HTML文件”  
          f   =   fso.GetFile(s);    
          ts   =   f.OpenAsTextStream(1,-2);    
          txt   =   ts.ReadAll(   );   //读全文  
          ts.Close(   );    
          txt=txt.toUpperCase();    
           
          titl=s.name;  
          start=txt.indexOf("<TITLE>",0);    
          if   (start!=-1){  
          start+=7;  
          end=txt.indexOf("</TITLE>",start);  
          if   (end!=-1)   titl=txt.substr(start,end-start);  
          }  
           
              document.write("<a   href=\""+s+"\">"+titl+"</a><br>");  
              }  
      }  
           
  }  
   
  HTMlist("C:\\My   Documents");  
  </script>

posted on 2011-07-26 00:33  网文随摘  阅读(678)  评论(0)    收藏  举报