要记时代码
前天,我发了一个问题,赏了50分,没想到分扣了,问题却没通过。都没能发表出来,到底那里的问题。
我要的代码是
需要在网页中插入一段代码
要求:
实现的效果
从2006年12月28号20点20分20秒到现在已经:1年10个月20天20分20秒
"从2006年12月28号20点20分20秒到现在已经:"这一段代码是固定的(当然要能在代码里改成任意的文字)
"1年10个月20天20分20秒"这段要谁随着时间的变化而变化.
答案好了,加50分.
网页正计时代码
答案:1 悬赏:60 手机版
解决时间 2021-02-02 21:44
- 提问者网友:别再叽里呱啦
- 2021-02-02 08:30
最佳答案
- 五星知识达人网友:罪歌
- 2021-02-02 08:58
<html>
<head>
<title>离开某一天日期</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body onLoad="startclock()">
<center>
<table border=0 bordercolor=blue borderlight=green style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr><td align=center height=100 width=400>
<SCRIPT LANGUAGE="JavaScript">
<!--
var timerID;
var timerRunning = false;
var today = new Date();
var startday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;
function stopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock()
{
stopclock();
showtime1();
}
function showtime1()
{
startday = new Date("Dec 28, 2006 20:20 EDT");
startday.setYear("2006");
today = new Date();
secsPerDay = 1000 ;
minPerDay = 60 * 1000 ;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
if (daysRemain == 1)
{
day_rem = " day, "
}
else
{
day_rem = " days, "
}
if (hoursRemain == 1)
{
hour_rem = " hour, "
}
else
{
hour_rem = " hours, "
}
if (minRemain == 1)
{
min_rem = " minute, "
}
else
{
min_rem = " minutes, "
}
if (secsRemain == 1)
{
sec_rem = " second"
}
else
{
sec_rem = " seconds"
}
timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain +
min_rem + secsRemain + sec_rem;
document.up.face.value = timeRemain;
timerID = setTimeout("showtime1()",1000);
timerRunning = true;
}
//-->
</SCRIPT>
<P>
<FONT SIZE=+1 FACE="Arial">
从2006年12月28号20点20分20秒到现在已经:
</FONT>
<FORM NAME="up">
<INPUT TYPE="text" NAME="face" SIZE="47" VALUE="A browser supporting JavaScript 1.1+ is needed.">
</FORM>
</td></tr>
</table></center>
<br>
<center>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function goHist(a)
{
history.go(a);
}
//-->
</script></center>
<br>
</body>
</html>
<head>
<title>离开某一天日期</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body onLoad="startclock()">
<center>
<table border=0 bordercolor=blue borderlight=green style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr><td align=center height=100 width=400>
<SCRIPT LANGUAGE="JavaScript">
<!--
var timerID;
var timerRunning = false;
var today = new Date();
var startday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;
function stopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock()
{
stopclock();
showtime1();
}
function showtime1()
{
startday = new Date("Dec 28, 2006 20:20 EDT");
startday.setYear("2006");
today = new Date();
secsPerDay = 1000 ;
minPerDay = 60 * 1000 ;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
if (daysRemain == 1)
{
day_rem = " day, "
}
else
{
day_rem = " days, "
}
if (hoursRemain == 1)
{
hour_rem = " hour, "
}
else
{
hour_rem = " hours, "
}
if (minRemain == 1)
{
min_rem = " minute, "
}
else
{
min_rem = " minutes, "
}
if (secsRemain == 1)
{
sec_rem = " second"
}
else
{
sec_rem = " seconds"
}
timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain +
min_rem + secsRemain + sec_rem;
document.up.face.value = timeRemain;
timerID = setTimeout("showtime1()",1000);
timerRunning = true;
}
//-->
</SCRIPT>
<P>
<FONT SIZE=+1 FACE="Arial">
从2006年12月28号20点20分20秒到现在已经:
</FONT>
<FORM NAME="up">
<INPUT TYPE="text" NAME="face" SIZE="47" VALUE="A browser supporting JavaScript 1.1+ is needed.">
</FORM>
</td></tr>
</table></center>
<br>
<center>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function goHist(a)
{
history.go(a);
}
//-->
</script></center>
<br>
</body>
</html>
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯