想要2个关于时间的代码... 第一个是展示时间...每秒变换...页面中的时间也跟着变换...第二个是倒计时...比如说倒计时5分钟...每秒钟的变化也能体现..... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 javascript中setTimeout和setInterval函数setTimeout(表达式,延时时间) 在执行时,是在载入后延迟指定时间后,去执行一次表达式,记住,次数是一次 用setTimeout实现的自动变化显示随机数的效果: <html> <head> <script> window.onload=sett; function sett() { document.body.innerHTML=Math.random(); setTimeout("sett()",500); } </script> </head> <body> </body> </html> setInterval(表达式,交互时间) 则不一样,它从载入后,每隔指定的时间就执行一次表达式 用setInterval实现的自动变化显示随机数的效果: <html> <head> <script> function sett() { document.body.innerHTML=Math.random(); } setInterval("sett();", 500); </script> </script> </head> <body> </body> </html> lz 以后发帖子尽量不要写【要代码】之类的词,见到这词一般我都会把帖子移到非技术区,因为要东西和讨论技术是两回事lz 的帖子可以写成【关于两个时间的设置问题】o(∩_∩)o...第一个好做,lz 自己应该能搞定我把第二的贴个代码给你,你参考一下:<!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" lang="gb2312"><head><head><title> 倒计时效果 </title><meta http-equiv="content-type" content="text/html; charset=gb2312" /><meta name="keywords" content="" /><meta name="description" content="" /><script language="JavaScript"><!-- //var startTime = new Date();var EndTime=startTime.getTime()+100*60*1000;function GetRTime(){var NowTime = new Date();var nMS =EndTime - NowTime.getTime();//var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));var nH=Math.floor(nMS/(1000*60*60)) % 24;var nM=Math.floor(nMS/(1000*60)) % 60;var nS=Math.floor(nMS/1000) % 60; //document.getElementById("RemainD").innerHTML=nD; document.getElementById("RemainH").innerHTML=nH; document.getElementById("RemainM").innerHTML=nM; document.getElementById("RemainS").innerHTML=nS;if(nMS>5*59*1000&&nMS<=5*60*1000){alert("还有最后五分钟!");}setTimeout("GetRTime()",1000);}window.onload=GetRTime;// --></script></head><body><div id="CountMsg">倒计时还有:<strong id="RemainD"></strong><strong id="RemainH">XX</strong>时<strong id="RemainM">XX</strong>分<strong id="RemainS">XX</strong>秒</div></body></html> 在jsp中获得当点击按钮增加一个input的值 设计模式 求助:jb2005得tomcat下部署jsp时,奇怪的错误 请问高手!用JBulider做的WEB程序怎么在jcreator里运行!帮帮小弟我!我的JBulider!或者告诉我个网站下载JBulider9的网站谢谢了 请教关于自动滚屏的问题! JS 实现弹出式复选框 jsp和mysql的问题小弟拜求再线等 图片在SQLSERVER中的存取!!!!!!! 请教一个servlet的问题 我是新手,诸位兄弟,帮帮忙! 为什么,一对多关系中,在“一”端里的“多”端数据集合都用set,而不用List? java 发送email程序
在执行时,是在载入后延迟指定时间后,去执行一次表达式,记住,次数是一次 用setTimeout实现的自动变化显示随机数的效果: <html>
<head>
<script>
window.onload=sett;
function sett()
{
document.body.innerHTML=Math.random();
setTimeout("sett()",500);
}
</script>
</head>
<body>
</body>
</html> setInterval(表达式,交互时间)
则不一样,它从载入后,每隔指定的时间就执行一次表达式 用setInterval实现的自动变化显示随机数的效果: <html>
<head>
<script>
function sett()
{
document.body.innerHTML=Math.random();
}
setInterval("sett();", 500);
</script>
</script>
</head>
<body>
</body>
</html>
第一个好做,lz 自己应该能搞定我把第二的贴个代码给你,你参考一下:
<!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" lang="gb2312">
<head>
<head>
<title> 倒计时效果 </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script language="JavaScript">
<!-- //
var startTime = new Date();
var EndTime=startTime.getTime()+100*60*1000;
function GetRTime(){
var NowTime = new Date();
var nMS =EndTime - NowTime.getTime();
//var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
//document.getElementById("RemainD").innerHTML=nD;
document.getElementById("RemainH").innerHTML=nH;
document.getElementById("RemainM").innerHTML=nM;
document.getElementById("RemainS").innerHTML=nS;
if(nMS>5*59*1000&&nMS<=5*60*1000)
{
alert("还有最后五分钟!");
}
setTimeout("GetRTime()",1000);
}
window.onload=GetRTime;
// -->
</script>
</head>
<body>
<div id="CountMsg">倒计时还有:<strong id="RemainD"></strong><strong id="RemainH">XX</strong>时<strong id="RemainM">XX</strong>分<strong id="RemainS">XX</strong>秒</div>
</body>
</html>