网页设计问题:在时间显示上遇到麻烦。

来源:百度知道 编辑:UC知道 时间:2024/05/27 09:23:15
我的这段Javascript代码为什么显示不了时间?
<html>
<head>
<script language="Javascript" type="text/Javascript">
function dateexample()
{today=new Date();
document.write("今天是:")
document.write(today.getYear());
document.write("年");
document.write(today.getMonth()+1);
document.write("月");
document.write(today.getDate());
document.write("日");
document.write(today.getDay())
{case0:document.write("星期日");break;
case0:document.write("星期一");break;
case0:document.write("星期二");break;
case0:document.write("星期三");break;
case0:document.write("星期四");break;
case0:document.write("星期五");break;
default:document.write("星期六");break}
document.write("<br>");
document.write("现在时间:");
document.write(today.getHours()+":");
do

说实话,有时候研究这段代码,不如从我资料库给你复制一段,你自己再慢慢琢磨吧:

<script language="JavaScript" type="text/javascript">
<!--
var enable=0;today=new Date();
var day;
var date;
var time_start=new Date();
var clock_start=time_start.getTime();
if (today.getDay()==0) day="日";
if (today.getDay()==1) day="一";
if (today.getDay()==2) day="二";
if (today.getDay()==3) day="三";
if (today.getDay()==4) day="四";
if (today.getDay()==5) day="五";
if (today.getDay()==6) day="六";
date=""+(today.getYear())+"年"+(today.getMonth()+1)+"月"+(today.getDate())+"日 星期";
document.write("<span style='font-size:9pt'>"+date);
document.write(day+"</span>");//--></script>