一个动态模拟时钟,鼠标移入钟面时,出现一个矩形指示牌,显示当天的日期和星期,鼠标移出时指示牌消失。
这个代码怎么写啊``` 

解决方案 »

  1.   

    下面的放在<body...>
    onLoad="startclock();"下面的放在<body></body>之间
    <script language="JavaScript">
    <!-- Hide
      var timerID = null
      var timerRunning = false
      function MakeArray(size) 
      {
      this.length = size;
      for(var i = 1; i <= size; i++)
      {
      this[i] = "";
      }
      return this;
      }
      function stopclock (){
      if(timerRunning)
      clearTimeout(timerID);
      timerRunning = false
      }
      function showtime () {
      var now = new Date();
      var year = now.getYear();
      var month = now.getMonth() + 1;
      var date = now.getDate();
      var hours = now.getHours();
      var minutes = now.getMinutes();
      var seconds = now.getSeconds();
      var day = now.getDay();
      Day = new MakeArray(7);
      Day[0]="星期天";
      Day[1]="星期一";
      Day[2]="星期二";
      Day[3]="星期三";
      Day[4]="星期四";
      Day[5]="星期五";
      Day[6]="星期六";
      var timeValue = "";
      timeValue += year + "年";
      timeValue += ((month < 10) ? "0" : "") + month + "月";
      timeValue += date + "日  ";
      timeValue += (Day[day]) + "  ";
      timeValue += ((hours <= 12) ? hours : hours - 12);
      timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
      timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
      timeValue += (hours < 12) ? "上午" : "下午";
      document.jsfrm.face.value = timeValue;
      timerID = setTimeout("showtime()",1000);
      timerRunning = true
      }
      function startclock () {
      stopclock();
      showtime()
      }
      //--></script>
      

  2.   


    一楼是可以用的,不过我用的是text组件试的,不知道jsfrm是个什么组件?楼主自己知道吗?去试试吧...
      

  3.   

    给你推荐一个网站,上面又好多解决你这样问题的,特别是做时钟效果的,我也是一不小心找到的。http://www.yesky.com/imagesnew/software/jscript/index.html