日期:2014-05-16  浏览次数:20479 次

java脚本如何实现与当前系统时间进行比较?
ASP做考勤系统,如何实现点击按钮时调用java脚本,实现特定时间与系统当前时间进行比较,并弹出小窗口,显示是否迟到(小于当前时间没有迟到,反之迟到)

------解决方案--------------------
改了一下,加了一个按钮

<!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>
<title> Delay Alert </title>
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "yixianggao@126.com " />
<meta name= "keywords " content= "javascript " />
<meta name= "description " content= "for javascript region of csdn " />
</head>

<body>
<input type= "button " id= "btnStart " value= "上班了 " onclick= "showDelayDetail(); " />
<script type= "text/javascript ">
<!--
function showDelayDetail()
{
var currentTime = new Date();
var officeStartTime = new Date();
// 早九点上班
officeStartTime.setHours(9, 0, 0)

var delayInterval = (currentTime - officeStartTime)/1000;

var message = " ";
// 迟到了
if (delayInterval > 0)
{
message += "恭喜恭喜,你今天迟到了 ";
var delayHours, delayMinutes, delaySeconds;

delayHours = Math.floor(delayInterval/3600);
delaySeconds = delayInterval % 3600;

delayMinutes = Math.floor(delaySeconds/60);
delaySeconds = delayInterval % 60;

message += delayHours + ": " + delayMinutes + ": " + delaySeconds;
}
else
{
message = "居然没迟到,哈! ";
}

alert(message);
}
//-->
</script>
</body>
</html>