///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
     分 时 问 候 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">

 

 

   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<body>与</body>之间

 


   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

var mess1="";

定义一个新变量。
document.write("<center><b> ")
设置格式,可以是字体,颜色等。
day = new Date( )
设置Date的一个新对象。
hr = day.getHours( )
把当前的“小时”的值赋给hr.
if (( hr >= 0 ) && (hr <= 4 ))
mess1="深夜了,
意身体,该休息了!"
在0--4点间,出现“清晨好,这麽早就上网呀?!”字样。以下,类推。
if (( hr >= 4 ) && (hr < 7))
mess1="清晨好,这麽早就上网呀?!"
if (( hr >= 7 ) && (hr < 12))
mess1="早上好,一天之际在于晨,又是美好的一天!"
if (( hr >= 12) && (hr <= 13))
mess1="该吃午饭啦!有什麽好吃的?"
if (( hr >= 13) && (hr <= 17))
mess1="外面的天气很热吧?!心静自然凉! "
if (( hr >= 17) && (hr <= 18))
mess1="太阳落山了!快看看夕阳吧!"
if ((hr >= 18) && (hr <= 19))
mess1="吃过晚饭了吗?"
if ((hr >= 19) && (hr <= 23))
mess1="一天过的可真快!今天过的好吗?"
同上。
document.write(mess1)
输出mess1的值。
document.write("</b> ") 字体设置结束。


  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页