当前位置: 代码迷 >> JavaScript >> JavaScript显示时间有关问题
  详细解决方案

JavaScript显示时间有关问题

热度:289   发布时间:2013-12-02 12:00:40.0
JavaScript显示时间问题
想用JavaScript写一个时间显示器,页面就是无法显示出来,空白,求助,我的源码如下,求高手指点。

<!DOCTYPE html>
<html>
    <head>
        <title>showtime.html</title>
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    </head>
    <body>
        <span>
            <script language="JavaScript">
                startclock();
                var timerID = null;
                var timerRunning = false;
                function showtime(){
                    var Today = new Date();
                    var NowHour = Today.getHours(); //HH
                    var NowMinute = Today.getMinutes(); //MM
                    var NowSecond = Today.getSeconds(); //SS
                    var NowMonth = Today.getMonth() + 1; //MMM
                    var NowDate = Today.getDate(); //dd
                    var NowYear = Today.getYear(); //yyyy
                    if (NowHour <= 9) 
                        NowHour = "0" + NowHour;
                    if (NowMinute <= 9) 
                        NowMinute = "0" + NowMinute;
                    if (NowSecond <= 9) 
                        NowSecond = "0" + NowSecond;
                    
                    var disTime = NowYear + "年" + NowMonth + "月" + NowDate + "日&nbsp;&nbsp;" + NowHour + ":" + NowMinute + ":" + NowSecond + "&nbsp;&nbsp;";
                    document.write(disTime);
                    if (NowDate == 1) {
                        disTime = disTime + "星期一";
                    }
                    if (NowDate == 2) {
                        disTime = disTime + "星期二";
                    }
                    if (NowDate == 3) {
                        disTime = disTime + "星期三";
                    }
  相关解决方案