C# 网页计时器

来源:百度知道 编辑:UC知道 时间:2024/09/28 07:31:30
做了一个用于考试的网站,C#写的,现在需要再网页中显示动态的时钟提示考试所剩时间,不知道怎么实现。好像再网页中只有刷新页面才可以使得时钟的值有变化。希望大家把忙解决一下!先谢了!

计时器代码如下(仅供参考)
<div id=test ></div>
<script>
var alltime=60;
function setTime(){
if (alltime<=0){
alert("时间到!");
clearInterval(s);
}
else{
alltime--;
m=Math.floor(alltime/60);
se=Math.round(alltime-(Math.floor(alltime/60)*60));
test.innerText="剩余"+m+"分"+se+"秒";
}
}
s=setInterval("setTime()",1000)
</script>
希望对你有帮组

用前台JS脚本实现

这个用ajax很容易实现的
用一个Label显示系统时间或是你想显示的时间
然后放到updatepanel中,然后放个定时器进去,定时一秒,就可以无刷新的动态显示时间了。
有什么不明白的再交流

动态的是服务器端时间。客户端就是你的IE所在的电脑。用前台实现
这是一段代码
<script language= JavaScript>
<!--
function showtimes(){
var now=new Date();
var str="当前时间:";
var hour=now.getHours();
var minutes=now.getMinutes();
var seconds=n