Created
June 26, 2013 16:23
-
-
Save jomasero/5868899 to your computer and use it in GitHub Desktop.
Contador de tiempo en página web.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
var startday = new Date(); | |
var clockStart = startday.getTime(); | |
function initStopwatch() | |
{ | |
var myTime = new Date(); | |
return((myTime.getTime() - clockStart) / 1000); | |
} | |
function getSecs() | |
{ | |
var tSecs = Math.round(initStopwatch()); | |
var iSecs = tSecs % 60; | |
var iMins = Math.round((tSecs-30)/60); | |
var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs); | |
var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins); | |
document.forms[0].timespent.value = sMins+":"+sSecs; | |
window.setTimeout('getSecs()',1000); | |
} | |
</script> | |
</head> | |
<body onload="window.setTimeout('getSecs()', 1)"> | |
<form> | |
<input size="5" name="timespent" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment