<html>
<head>
<title>JavaScript创建文件夹</title>
<script type="text/javascript">
//创建目录
var fso = new ActiveXObject("Scripting.FileSystemObject");
function createDir(){
fso.CreateFolder("C:/Documents and Settings/zhuj/桌面/test/folder/folder1");
}
function getDirExists(){
alert(fso.FolderExists("C:/Documents and Settings/zhuj/桌面/test/folder1"));
}
function getValue(){
var s = document.getElementById("SI_ID");
alert(s.selectedIndex);
alert(s.options[s.selectedIndex].value);
}
//验证手机号
function validatePhone(){
var num = document.getElementById("phone").value;
var regx = /(^1[3-9]\d{9}$)|(^01[3-9]\d{9}$)/;
var reg = /^01[3-9]\d{9}$/;
alert(regx.test(num));
if(reg.test(num)){
alert(num.slice(1));
}
}
//处理日期
var t1, t2;
var today = new Date();
alert(today);
alert(Date.parse("2012/12/12 12:12:12"));
alert(new Date("2012/12/12 12:12:12"));
function showCurrentTime(txtId){
alert(parseFloat(5.5555) - 10);
var now = new Date();
var txt = document.getElementById(txtId);
txt.innerHTML = now.getFullYear() + "-" + now.getMonth() + "-" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
if("curTime1" == txtId){
t1 = now.getTime();
} else {
t2 = now.getTime();
}
}
function compute(curTimeId){
var t = t2 - t1;
var curTime = document.getElementById(curTimeId);
curTime.innerHTML = t;
}
</script>
</head>
<body>
<input type="button" value="创建文件夹" onclick="createDir();"/>
<input type="button" value="判断目录是否存在" onclick="getDirExists();"/>
<select id="SI_ID" name="SI_ID" style="width: 150px;" >
<option value="1">------请选择1------</option>
<option value="2">------请选择2------</option>
<option value="3">------请选择3------</option>
<option value="4">------请选择4------</option>
</select>
<input type="button" value="显示select的值" onclick="getValue();"/><br/>
<input type="text" id="phone"/>
<input type="button" value="判断是否是手机号" onclick="validatePhone();"/>
<br/>
<input type="button" value="显示当前时间和毫秒数1" onclick="showCurrentTime('curTime1');"/><span id="curTime1"></span><br/>
<input type="button" value="显示当前时间和毫秒数2" onclick="showCurrentTime('curTime2');"/><span id="curTime2"></span><br/>
<input type="button" value="计算时间相差秒数" onclick="compute('curTime');"/><span id="curTime"></span><br/>
<table>
<tr></tr>
</table>
</body>
</html>