.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Clock in Javascript

Posted By:Athira Sreejith       Posted Date: February 23, 2009    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  
 

Display Clock using Javascript in your asp.net application

var MS=navigator.appVersion.indexOf("MSIE") window.isIE4 = (MS>0) && (parseInt(navigator.appVersion) >= 4) function lead0(val)
{
// add leading 0s when necessary return val<10 ? "0"+val.toString() : val
}
function buildTime()
{
var time = new Date() var ampm = " AM" var h=time.getHours()
// fix military time and determine ampm if (h > 12)
{
h = h - 12; ampm = " PM";
}
return h+":"+lead0(time.getMinutes())+":"+ lead0(time.getSeconds()) + "" + ampm
}
function tick()
{
// Replace the plain-text contents of the clock element document.all.clock.innerText = buildTime()
} // Start clock when page is loaded. function startclock(){ if (window.isIE4) ( setInterval('tick()',1000) )
}
function dark(colnum)
{
if(document.getElementsByTagName)
{
var table = document.getElementById('thetable'); var col = table.getElementsByTagName("td"); col[colnum].className = "effect";
}
}
function light(colnum)
{
if(document.getElementsByTagName){ var table = document.getElementById('thetable'); var col = table.getElementsByTagName("td"); col[colnum].className = "return";
}
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend