Creating a Clock Object and Displaying the Results on the Page : Time : Development JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Development » Time »

 

Creating a Clock Object and Displaying the Results on the Page



<html>
<head>
  <title>JavaScript Unleashed</title>
  <script type="text/javascript">
  <!--
    function Clock (hours, minutes){
     this.hours = hours;
     this.minutes = minutes;
     this.setTime = setTime;
     this.displayTime = displayTime;
    }
   
    function setTime (hours, minutes){
     this.hours = hours;
     this.minutes = minutes;
    }
   
    function displayTime (){
      var line = this.hours + ":" this.minutes;
      document.write ("<hr>Time of clock:  " + line);
    }
  //-->
  </script>
</head>
<body>
  <script type="text/javascript">
  <!--
    var currTime = new Date();
    var myClock = new Clock(currTime.getHours (), currTime.getMinutes ());
    myClock.displayTime ();  //-->
  </script>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Development
» Time