<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>时间段提示</title>
<script>
var date=new Date()
var h=date.getHours()//获取当前时间
if(h>=0&&h<12){
alert('早上好!')
}else if(h>=12 &&h<18){
alert('下午好!')
}else if(h>=18 &&h<=24){
alert('晚上好!')
}
</script>
</head>
希望对你有用。
在<head></head>之间插入JAVASCRIPT代码<script language="JavaScript" type="text/javascript">
function showTime(){
var mytime=new Date()
var h=mytime.getHours()
var m=mytime.getMinutes()
var s=mytime.getSeconds()
if(h<10) h="0"+h
if(m<10) m="0"+m
if(s<10) s="0"+s
word.innerHTML=h+":"+m+":"+s
setTimeout("showTime()",1000)
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'")
if (restore) selObj.selectedIndex=0
}
function MM_findObj(n, d) { //v4.01
var p,i,x if(!d) d=documentif((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].documentn=n.substring(0,p)}
if(!(x=d[n])&&d.all) x=d.all[n]for (i=0!x&&i<d.forms.lengthi++) x=d.forms[i][n]
for(i=0!x&&d.layers&&i<d.layers.lengthi++) x=MM_findObj(n,d.layers[i].document)
if(!x &&d.getElementById) x=d.getElementById(n)return x
}
function MM_jumpMenuGo(selName,targ,restore){ //v3.0
var selObj = MM_findObj(selName)if (selObj) MM_jumpMenu(targ,selObj,restore)
}
</script>
然后在你想要显示的地方插入代码
<div class="STYLE3" id="word"></div>
<div id="time1">id is hang_2
</div>
<script>
setInterval("document.getElementById('time1').innerHTML = new Date().toLocaleString()", 1000)
</script>
在右上角位置放上这个DIV
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)