C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Display Running Time of a Page using JavaScript


Posted Date: 23 Jun 2008    Resource Type: Code Snippets    Category: Javascript

Posted By: Kapil Dhawan       Member Level: Gold
Rating:     Points: 5



The code sample shows how to calculate the time for which the page has been open. Such timings are particularly useful when designing online tests,etc.

The main part of the code is the DateTime() function. This function gets the current timing and is called every 500 milliseconds. The first DateTime() is called after the body of the page is loaded. The subsequent calls are made using setTimeout() function


<script type="text/javascript">

function DateTime()
{
var today=new Date();
var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();

minutes=checkTime(m);
seconds=checkTime(s);
document.getElementById('txtDate').innerHTML=hours+":"+minutes+":"+seconds;
time=setTimeout('DateTime()',500);
}

function checkTime(count)
{
if (count<10)
{
count="0" + count;
}
return count;
}


<body onload="DateTime()">

< div id="txtDate">
< /div>

</body>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Show running time of a page  .  Display running time using javascript  .  Display running time on a page  .  Display running time of a page  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Convert Celsius from/to Fahrenheit
Previous Resource: Get Browser's Name and Version using Javascript
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use