Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <style>
- #time {
- color: white;
- font-family: Arial;
- font-size: 100px;
- }
- </style>
- <script>
- function startTimer(duration, display) {
- var timer = duration, minutes, seconds;
- var intv = setInterval(function () {
- minutes = parseInt(timer / 60, 10);
- seconds = parseInt(timer % 60, 10);
- minutes = minutes < 10 ? "0" + minutes : minutes;
- seconds = seconds < 10 ? "0" + seconds : seconds;
- display.textContent = minutes + ":" + seconds;
- if (--timer < 0) {
- clearInterval(intv);
- }
- }, 1000);
- }
- window.onload = function () {
- var time = parseInt(window.location.hash.substring(1)),
- display = document.querySelector('#time');
- startTimer(time, display);
- };
- </script>
- </html>
- <body>
- <div id="time"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment