日期:2014-05-18  浏览次数:21348 次

页面上能否显示动态时间
网页上能否显示像电子表一样的动态时间,?
请高手指点

------解决方案--------------------
<html>
<head>
<SCRIPT language="JavaScript">

// 显示当前时间和日期
function dtview()
{
//输出时间
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()

if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock=hours+":"+minutes+":"+seconds;
setTimeout("dtview()",1000)
time_area.innerHTML = myclock;
}
</SCRIPT>
</head>
<body onLoad="dtview();">
<div id="time_area"></div>
</body>
</html>
------解决方案--------------------
<title> 带有倒影的时间 </title>
<html>
<head>
<style type="text/css">
<!-- 
.time{
font-family : Comic Sans Ms;
font-size : 14pt;
font-weight : bold;
color: #00008D;
}
-->
</style>
<style type="text/css">
<!-- 
.time{
font-family : Comic Sans Ms;
font-size : 14pt;
font-weight : bold;
color: #00008D;
}
-->
</style>
</head>
<script Language="JavaScript">
<!-- Hiding
var ctimer;
function init(){
if (document.all){
tim2.style.left=tim1.style.posLeft;
tim2.style.top=tim1.style.posTop+tim1.offsetHeight-6;
settimes();
}
}
function settimes(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
if (hours<10)
hours="0"+hours;
if(mins<10)
mins="0"+mins;
if (secs<10)
secs="0"+secs;
tim1.innerHTML=hours+":"+mins+":"+secs
tim2.innerHTML=hours+":"+mins+":"+secs
ctimer=setTimeout('settimes()',960);}
// -->
</script>
<body onLoad="init()">
<div align="center" Id="tim1" Style="position:absolute; width:10; height:10; top:10; left:50"
class="time"></div><div Id="tim2"
Style="position:absolute; filter:flipv() alpha(opacity=20); font-style:italic"
class="time"></div>
</body>
<script Language="JavaScript">
<!-- Hiding
var ctimer;
function init(){
if (document.all){
tim2.style.left=tim1.style.posLeft;
tim2.style.top=tim1.style.posTop+tim1.offsetHeight-6;
settimes();
}
}
function settimes(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
if (hours<10)
hours="0"+hours;
if(mins<10)
mins="0"+mins;
if (secs<10)
secs="0"+secs;
tim1.innerHTML=hours+":"+mins+":"+secs
tim2.innerHTML=hours+":"+mins+":"+secs
ctimer=setTimeout('settimes()',960);
}
// -->
 </script>
</html> 
<div id="Layer551" style="position:absolute; left:585px; top:6px; width:200px; height:52px; z-index:1">
------解决方案--------------------
<label id="aa"></label>
<script>
setInterval("aa.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script>

或者使用ajax吧