日期:2014-05-16 浏览次数:20377 次
var date = new Date(); var time = date.getTime(); setTimeout(function(){ var date1 = new Date(); var time2 = date1.getTime() - time ; alert("时间过了" +time2/1000+"秒"); },5000);
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
var indate = new Date();
function showTime(){
var todate = new Date();
var timelong = todate - indate;
var h = parseInt(timelong/3600000,10);
var m = parseInt(timelong%3600000/60000,10);
var s = timelong%60000/1000;
document.getElementById("div1").innerHTML = h + "小时" + m + "分" + s + "秒"
setTimeout("showTime()",1000);
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="showTime()">
<div id="div1"><div>
</BODY>
</HTML>
------解决方案--------------------
楼主你要的是js时钟。。。。汗~~~得加强表达能力
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <SCRIPT language=javascript> <!-- function Year_Month(){ var now = new Date(); var yy = now.getYear(); var mm = now.getMonth(); var mmm=new Array(); mmm[0]="January"; mmm[1]="February "; mmm[2]="March"; mmm[3]="April"; mmm[4]="May"; mmm[5]="June"; mmm[6]="July"; mmm[7]="August"; mmm[8]="September"; mmm[9]="October"; mmm[10]="November"; mmm[11]="December"; mm=mmm[mm]; return(mm ); } function thisYear(){ var now = new Date(); var yy = now.getYear(); return(yy ); } function Date_of_Today(){ var now = new Date(); return(now.getDate() ); } function CurentTime(){ var now = new Date(); var hh = now.getHours(); var mm = now.getMinutes(); var ss = now.getTime() % 60000; ss = (ss - (ss % 1000)) / 1000; var clock = hh+':'; if (mm < 10) clock += '0'; clock += mm+':'; if (ss < 10) clock += '0'; clock += ss; return(clock); } function refreshCalendarClock(){ document.all.calendarClock1.innerHTML = Year_Month(); document.all.calendarClock2.innerHTML = Date_of_Today(); document.all.calendarClock3.innerHTML =thisYear(); document.all.calendarClock4.innerHTML = CurentTime(); } document.write('<font id="calendarClock1" > </font> '); document.write('<font id="calendarClock2" > </font>,'); document.write('<font id="calendarClock3" > </font> '); document.write('<font id="calendarClock4" > </font>'); refreshCalendarClock(); setInterval('refreshCalendarClock()',1000); //--> </SCRIPT> </BODY> </HTML>
------解决方案--------------------