<html>
<head>
<script language="javascript" >
xx=new Date(); var s = (xx.getHours()*3600+xx.getMinutes()*60+xx.getSeconds()); var tim_d = parseInt(s/86400);
var tim_h = parseInt((s%86400)/3600);
var tim_m = parseInt(((s%86400)%3600)/60);
var tim_s = ((s%86400)%3600)%60;
function setime()
{
if(tim_s>=60)
{
tim_s = 0;//60
if(tim_m>=60)
{
tim_m=0;//60
//小时数
if(tim_h>=24)
{
window.clearTimeout(xx);
}
tim_h+=1;
}
tim_m += 1;
}
tim_s+=1;
if(tim_s<10)
{
show_s = "0" + tim_s;
}
else
{
show_s = tim_s;
}
if(tim_m < 10)
{
show_m = "0" + tim_m;
}
else
{
show_m = tim_m;
}
if(tim_h < 10)
{
show_h = "0" + tim_h;
}
else
{
show_h = tim_h;
}
show_d = tim_d;
document.getElementById("div1").innerHTML=(show_h+"时"+show_m+"分"+show_s+"秒");
xx=setTimeout("setime()",1000);
}
</script>
<script language=javascript defer>
var key=1;
if(key==1){
setime();
}
</script>
<body>
<div id="div1">
</div>
</body></html>
<head>
<script language="javascript" >
xx=new Date(); var s = (xx.getHours()*3600+xx.getMinutes()*60+xx.getSeconds()); var tim_d = parseInt(s/86400);
var tim_h = parseInt((s%86400)/3600);
var tim_m = parseInt(((s%86400)%3600)/60);
var tim_s = ((s%86400)%3600)%60;
function setime()
{
if(tim_s>=60)
{
tim_s = 0;//60
if(tim_m>=60)
{
tim_m=0;//60
//小时数
if(tim_h>=24)
{
window.clearTimeout(xx);
}
tim_h+=1;
}
tim_m += 1;
}
tim_s+=1;
if(tim_s<10)
{
show_s = "0" + tim_s;
}
else
{
show_s = tim_s;
}
if(tim_m < 10)
{
show_m = "0" + tim_m;
}
else
{
show_m = tim_m;
}
if(tim_h < 10)
{
show_h = "0" + tim_h;
}
else
{
show_h = tim_h;
}
show_d = tim_d;
document.getElementById("div1").innerHTML=(show_h+"时"+show_m+"分"+show_s+"秒");
xx=setTimeout("setime()",1000);
}
</script>
<script language=javascript defer>
var key=1;
if(key==1){
setime();
}
</script>
<body>
<div id="div1">
</div>
</body></html>
解决方案 »
- 求救 confirm 关闭事件问题
- IE和FF对span的样式兼容
- 仿google suggest有问题啊!各路江湖好汉看下啊!
- javascript十六进制转换问题,轻松100分
- var ary=new array()的思考
- 批次验证文件框有效性--vbscript或javascript都可以
- 什么工具写javascript有对象属性提示的?
- 全局变量的问题
- 错误:未定义的对象
- AJAX跨域不执行success也不执行error,complete也不执行。
- 提示缺少对象,可是我觉得没错阿
- 有个下拉列表框,其中有一项值是”其它“,在下拉列表框的下面有三个文本框,当选择了下拉列表框中得”其它“时,下面得三个文本框就不让
<body onload=showTime()>
<span id=sp> </span>
</body>
<script>
function showTime()
{
var o = (new Date()).toLocaleString();
var t = o.split(" ")[1].split(":")
var time = t[0]+"时"+t[1]+"分"+t[2]+"秒";
document.getElementById('sp').innerText = time;
}
setInterval("showTime();",1000);
</script>
<HEAD>
<TITLE> Test</TITLE>
<SCRIPT LANGUAGE="JavaScript"> function gettime() { var t = new Date(); var hours = t.getHours(); var minutes = t.getMinutes(); var seconds = t.getSeconds(); var show_str =""; show_str +=(hours > 12) ? "下午 ": "上午 "; show_str += ((hours > 12) ? hours-12 : hours); show_str += ((minutes <10) ? ":0" : ":") + minutes; show_str += ((seconds <10) ? ":0" : ":") + seconds; document.show_time.name1.value = show_str;
//document.write(show_str);
t = setTimeout("gettime()",1000); }
</SCRIPT>
</HEAD>
<BODY onLoad="gettime()">
<BODY>
<FORM NAME="show_time" onSubmit="0">
<INPUT TYPE="text" NAME="name1" SIZE=16 VALUE="">
</FORM>
</BODY>
</HTML>
<img src="http://community.csdn.net/logo/images/prj.210.67.gif" id=pic>
<span id=sp style="position:absolute;left:10;top:20;"> </span>
</body>
<script>
function showTime(){
var o = (new Date()).toLocaleString();
var t = o.split(" ")[1].split(":")
var time = t[0]+"时"+t[1]+"分"+t[2]+"秒";
document.getElementById('sp').innerHTML = "<font color=blue>"+time+"</font>";
}setInterval("showTime();",1000);
</script>