网站头部动态日期--JS实现
来源:互联网 发布:jre 8u151 windows 编辑:程序博客网 时间:2024/05/22 01:27
<script language='javascript'>
today=new Date();
var day; var date; var hello; var wel;
hour=new Date().getHours()
if(hour < 6)hello='凌晨好'
else if(hour < 9)hello='早上好!'
else if(hour < 12)hello='上午好!'
else if(hour < 14)hello='中午好!'
else if(hour < 17)hello='下午好!'
else if(hour < 19)hello='傍晚好!'
else if(hour < 22)hello='晚上好!'
else ...{hello='夜里好!'}
if(today.getDay()==0)day='星期日'
else if(today.getDay()==1)day='星期一'
else if(today.getDay()==2)day='星期二'
else if(today.getDay()==3)day='星期三'
else if(today.getDay()==4)day='星期四'
else if(today.getDay()==5)day='星期五'
else if(today.getDay()==6)day='星期六'
date=(today.getYear())+'年'+(today.getMonth() + 1 )+'月'+today.getDate()+'日';
if(hour<1)wel='子时';
else if(hour<3)wel='丑时';
else if(hour<5)wel='寅时';
else if(hour<7)wel='卯时';
else if(hour<9)wel='辰时';
else if(hour<11)wel='巳时';
else if(hour<13)wel='午时';
else if(hour<15)wel='未时';
else if(hour<17)wel='申时';
else if(hour<19)wel='酉时';
else if(hour<21)wel='戌时';
else if(hour<23)wel='亥时';
else ...{wel='子时';}
</script>
today=new Date();
var day; var date; var hello; var wel;
hour=new Date().getHours()
if(hour < 6)hello='凌晨好'
else if(hour < 9)hello='早上好!'
else if(hour < 12)hello='上午好!'
else if(hour < 14)hello='中午好!'
else if(hour < 17)hello='下午好!'
else if(hour < 19)hello='傍晚好!'
else if(hour < 22)hello='晚上好!'
else ...{hello='夜里好!'}
if(today.getDay()==0)day='星期日'
else if(today.getDay()==1)day='星期一'
else if(today.getDay()==2)day='星期二'
else if(today.getDay()==3)day='星期三'
else if(today.getDay()==4)day='星期四'
else if(today.getDay()==5)day='星期五'
else if(today.getDay()==6)day='星期六'
date=(today.getYear())+'年'+(today.getMonth() + 1 )+'月'+today.getDate()+'日';
if(hour<1)wel='子时';
else if(hour<3)wel='丑时';
else if(hour<5)wel='寅时';
else if(hour<7)wel='卯时';
else if(hour<9)wel='辰时';
else if(hour<11)wel='巳时';
else if(hour<13)wel='午时';
else if(hour<15)wel='未时';
else if(hour<17)wel='申时';
else if(hour<19)wel='酉时';
else if(hour<21)wel='戌时';
else if(hour<23)wel='亥时';
else ...{wel='子时';}
</script>
测试效果:<table border="0" width="120" cellspacing="0" cellpadding="0">
<tr height="19" align="center">
<td>
<script>document.write("大家,"+hello);</script>
</td>
</tr>
<tr height="19" align="center">
<td style="border-bottom:#000000 solid 1px;padding:0 0 2 0;">
<SCRIPT>document.write(date+day)</SCRIPT>
</td>
</tr>
<tr height="19" align="center">
<td style="padding:0 0 4 0;">www.lrn.cn</td>
</tr>
</table>
把JS代码与测试代码写到同一个HTML页面中运行。
- 网站头部动态日期--JS实现
- js网站头部
- JS实现动态的日期选择表单
- js获取当前日期,网页头部用
- 网站头部回弹广告js代码
- JS动态显示日期时间
- 网页JS日期动态显示
- php discuz 总结 头部用户登录状态 js 动态生成
- JS实现日期加减
- js实现日期选择器
- js实现日期比较
- js实现日期选择器
- js实现日期大写
- js实现日期大写
- 实现js的日期
- js实现日期控件
- js实现日期格式化
- js实现日期控件
- 深入了解struts中的struts-config.xml [转]
- Windows Vista/Windows 2008 Server新增API一览
- Struts中不同的Action和ActionForm组合
- “奔奔族”理财:献给七八十年代生人
- ALV GRID的参考文档(VI)
- 网站头部动态日期--JS实现
- 楼市淘宝:2000元到8000元收入不同的购房理财经
- C#.net编写摄像头驱动程序,用avicap32.dll
- 微软最终用Silverlight作为产品交付的方式
- [转]什么是SDH
- 使用Struts之ActionForm
- asp.net窗体身份验证方案
- [Windows网络操作]Windows 系列操作系统远程控制
- Frash man