大家自己运行看看吧。
1、判断网页是否过期 getTime()
用于实现广告过期。
<head>
<h1>判断网页是否过期</h1>
<hr>
<script>
<!--
today = new Date() //取得现在的时间
TheDay = new Date(2005,12,31) //取得结束的时间 2006/1/4 00:00:00
//如果 today.getTime() > TheDay.getTime()
if (today.getTime()>TheDay.getTime())
{
document.write('<h1>抱歉,你访问的网页已经过期!</h1>') }
else
{
document.write('<font size=5>你的网页尚未过期.</font>')
}
//-->
</script>
2、在线时钟实例 setTimeout()函数
setTimeout()函数
TimerID = setTimeout('showtime',1000)
通过setTimeout 来刷新时间 间隔1000=1秒
<head>
<script>
<!--
function showtime()
{
document.CLOCK.ALARM.value = new Date().toString()
TimerID = setTimeout("showtime()",1000)
}
//-->
</script>
</head>
<body onLoad="showtime()">
<Form name="CLOCK">
<input name="ALARM" type="text" size="45" value="">
如无效果请刷新
</form>
</body>
在百度中搜索推荐几个JS实例:时钟广告跳转状态栏等

