javascript Enumerator

来源:互联网 发布:seo文章编辑器 编辑:程序博客网 时间:2024/05/29 06:42
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>"><!--<link rel="stylesheet" type="text/css" href="styles.css">// Enumerator此对象仅在 Internet Explorer 中受支持// atEnd 方法 | item 方法 | moveFirst 方法 | moveNext 方法// foreach(process, function(i, object);--> <script type="text/javascript">foreach();function foreach(){var bytesPerGB = 1024 * 1024 * 1024;// https://msdn.microsoft.com/zh-cn/library/aa711216(v=vs.71).aspx// FileSystemObject | Drive | Folder | Filevar fso = new ActiveXObject("Scripting.FileSystemObject");document.write(fso.Drives);var e = new Enumerator(fso.Drives);var driveString = "";e.moveFirst();while (e.atEnd() == false){    var drv = e.item();    driveString += drv.Path + " - ";    if (drv.IsReady)    {        var freeGB = drv.FreeSpace / bytesPerGB;        var totalGB = drv.TotalSize / bytesPerGB;                // toFixed() 方法可把 Number 四舍五入为指定小数位数的数字        driveString += freeGB.toFixed(3) + " GB free of ";        driveString += totalGB.toFixed(3) + " GB";    }    else    {        driveString += "Not Ready";    }    driveString += "<br />";        e.moveNext();}    document.write(driveString);    }</script>  </head>  <body>  </body></html>

0 0