| Site Map | WizTools.org | jCraze Blog |
![]()
|
JavaScript Dynamic Time UpdateLong back, when I wanted to display Time in my website, the only code that I could get my had on were those displaying the time in a text form. But now with advancements in JavaScript specification, the following is possible:
The code? You need to have a HTML span element with id 'dt' (or whatever name you wish to give): <span id="dt"></span> Now write the code to add dynamic 'inner HTML' to this element:
<script language="javascript">
setInterval('dispDate()', 1000);
function dispDate(){
myDate = new Date();
document.getElementById('dt').innerHTML = myDate;
}
</script>
The setInterval() function calls the function dispDate() once in every 1000 milliseconds (1000 milliseconds = 1 second). And in this function we set the new Date in the layer 'dt'. That's it folks! |
Sign Guestbook
|
Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.