专用秒表
<!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>专用秒表</title>
<script language="javascript">
var zt;
var jsk,jsx,jssum=0;
var typetime;
zt=0; //zt=0 停止|zt=1计时|zt=2暂停
</script>
<script language="javascript">
function js()
{
if(zt==1)
{
var now=new Date();
jsx=now.getTime();
typetime=jssum+(jsx-jsk)/1000;
document.form1.Textbox1.value=typetime.toFixed(3);
}
}
function ktsubmit()
{
if(zt==0)
{
zt=1;
var now=new Date();
jsk=now.getTime();
document.form1.button1.value="停止";
document.form1.button2.disabled=false;
}
else
{
zt=0;
document.form1.button1.value="开始";
document.form1.button2.value="暂停";
document.form1.button2.disabled=true;
document.form1.Textbox1.value="0.000";
jssum=0;
}
}
function zjsubmit()
{
if(zt==1)
{
zt=2;
jssum=jssum+(jsx-jsk)/1000
document.form1.button2.value="继续";
}
else
{
zt=1;
var now=new Date();
jsk=now.getTime();
document.form1.button2.value="暂停";
}
}
setInterval("js()",1)
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
专用秒表<br><br>
<input name="Textbox1" type="text" id="Textbox1" value="0.000" />
<input type="button" name="button1" id="button1" value="开始" onclick="ktsubmit()"/>
<input type="button" name="button2" id="button2" value="暂停" onclick="zjsubmit()"
disabled="disabled"/>
</form>
</body>
</html>