Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Powered by JavaScript
- <style>
- #timer, #controls {
- margin: 15px auto;
- width: 400px;
- border-radius: 20px;
- text-align: center;
- }
- #timer {
- font-size: 56px;
- border: 1px solid black;
- color: #442C14;
- background-color: #ff8866;
- }
- a {
- color: black;
- text-decoration: none;
- }
- a:hover {
- text-decoration: underline;
- }
- </style>
- <script>
- var timer;
- function startTimer() {
- timer = setInterval(setTime, 1000);
- }
- function stopTimer() {
- clearInterval(timer);
- }
- function viewCode(){
- myWindow=window.open('','','width=200,height=200, menubar=yes,status=yes, resizable=yes');
- myWindow.document.write("<p>This is 'myWindow'</p>");
- myWindow.focus();
- }
- </script>
- <div id="timer">
- </div>
- <div id="controls">
- <a href="#" onclick="startTimer()">Start timer</a>
- <a href="#" onclick="stopTimer()">Stop timer</a>
- <a href="#" onclick="viewCode()">View my code</a>
- </div>
- <script>
- function setTime() {
- var time = new Date();
- var hours = time.getHours();
- if (hours < 10) {
- hours = "0" + hours;
- }
- var minutes = time.getMinutes();
- if (minutes < 10) {
- minutes = "0" + minutes;
- }
- var seconds = time.getSeconds();
- if (seconds < 10) {
- seconds = "0" + seconds;
- }
- document.getElementById("timer").innerHTML = hours + " : " + minutes + " : " + seconds;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement