asp.net中将js的返回值赋给asp.net控件的小例子
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:varsecond=0;varminute=0;varhour=0;window.setInterval("OnlineS...
复制代码 代码如下:
<script language ="javascript" type ="text/javascript">
var second=0;
var minute=0;
var hour=0;
window .setInterval ("OnlineStayTimes();",1000);
function OnlineStayTimes()
{
second ++;
if(second ==60){second =0;minute +=1;}
if(minute ==60){minute =0;hour +=1;}
var tm=hour+"小时"+minute +"分钟"+second +"秒"
document.getElementById ("time").innerHTML=tm;
}
</script>
上面代码中document.getElementById ("time").innerHTML=tm;中“time”是label的id,这样即可实现显示在线时间的功能!