62,074
社区成员
发帖
与我相关
我的任务
分享
<!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>无标题页</title>
</head>
<body>
<input type="text" id="txt"/><input type="button" id="btn" value="daojishi" onclick="myfunc()"/>
<script type="text/javascript">
var m=0;
var s=0;
function myfunc(){
m=document.getElementById("txt").value;
s=60*m;
daojishi();
}
function daojishi(){
if(s==0){
//计时完毕
document.getElementById("btn").disabled=false;
document.getElementById("btn").value="计时完毕";
}
else{
s=s-1;
document.getElementById("btn").value=s;
document.getElementById("btn").disabled=true;
window.setTimeout("daojishi()",1000);
}
}
</script>
</body>
</html>
剩余时间:<span id="endtime">100</span>
<script type="text/javascript">
var CID = "endtime";
if (window.CID != null) {
var iTime = document.getElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime() {
var iDay, iHour, iMinute, iSecond;
var sDay = "", sHour = "", sMinute = "", sSecond = "", sTime = "";
if (iTime >= 0) {
iDay = parseInt(iTime / 24 / 3600);
if (iDay > 0) {
sDay = iDay + "天";
}
iHour = parseInt((iTime / 3600) % 24);
if (iHour > 0) {
sHour = iHour + "小时";
}
iMinute = parseInt((iTime / 60) % 60);
if (iMinute > 0) {
sMinute = iMinute + "分钟";
}
iSecond = parseInt(iTime % 60);
if (iSecond >= 0) {
sSecond = iSecond + "秒";
}
if ((sDay == "") && (sHour == "")) {
sTime = "<span style='color:darkorange'>" + sMinute + sSecond + "</font>";
}
else {
sTime = sDay + sHour + sMinute + sSecond;
}
if (iTime == 0) {
clearTimeout(Account);
sTime = "<span style='color:green'>时间到了!</span>";
}
else {
Account = setTimeout("RemainTime()", 1000);
}
iTime = iTime - 1;
}
else {
sTime = "<span style='color:red'>倒计时结束!</span>";
}
document.getElementById(CID).innerHTML = sTime;
}
</script>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Timer.ascx.cs" Inherits="TheContest.UserControls.Timer" %>
<script language="javascript" type="text/javascript">
var time=new Date();
time.setHours(0);
time.setMinutes(0);
time.setSeconds(0);
function myfun()
{
var sec=time.getSeconds();
document.myclock.value="已耗时:"+time.getHours()+"时"+time.getMinutes()+"分"+time.getSeconds()+"秒";
time.setSeconds(sec+1);
setTimeout("myfun()",1000);
}
</script>
<input name="myclock" type="text" style="width: 200px; height: 100px; background-color: #46B5FF; font-family: 幼圆; font-size: 30px; font-weight: bold;" />
<html>
<body>
<input type="text" id="clock" size="35" />
<script type="text/javascript">
var hour = 0;
var minute = 1;
var second = 10;
var index = self.setInterval("myfun()",1000);
function myfun(){
second = second - 1;
if(second == 0){
minute = minute - 1;
if(hour == 0 && minute == 0 && second == 0){
document.getElementById("clock").value="abc:" + hour + "de" + minute + "fg" + second + "hi";
return window.clearInterval(index);
}
second = 60;
if(minute == 0){
minute = 60;
hour = hour - 1;
}
}
document.getElementById("clock").value="剩余时间:" + hour + "小时 " + minute + "分钟 " + second + "秒";
}
</script>
</body>
</html>