jsp页面动态显示时间
<SCRIPT language="JavaScript">
function disptime(){
var time = new Date();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
var year = time.getFullYear();
var month = time.getMonth() + 1;
var date = time.getDate();
var day0 = time.getDay();
var day = "";
switch(day0){
case 1:day = "星期一";break;
case 2:day = "星期二";break;
case 3:day = "星期三";break;
case 4:day = "星期四";break;
case 5:day = "星期五";break;
case 6:day = "星期六";break;
case 0:day = "星期日";break;
}
minute="0"+minute;
if (second < 10)
second="0"+second;
var time = year + "/" + month + "/" + date + " " + day + " " + apm + " " + hour + ":" + minute + ":" + second;
document.getElementById("clock").innerHTML = time;
setTimeout("disptime()",1000);
}
</SCRIPT>
<body leftmargin="0" topmargin="0" class="footer" onload="disptime()">
<form NAME="myform">
<span style="float:right" id="clock"></span>
<span style="float:center">XXXXXXXXXXXXXXXXXX</span>
</form>
</body>
</html>
PS:
IE中float布局将center写在前会导致right的换行显示,这时需要将right的写在前面,即可解决。
chrome中前后无影响。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。