+ 1
Why does not the clock code work when I run it on my computer's browser ?
function printTime() { var d = new Date(); var hours = d.getHours(); var mins = d.getMinutes(); var secs = d.getSeconds(); document.body.innerHTML = hours+":"+mins+":"+secs; } setInterval(printTime, 1000);
6 Answers
+ 3
Again, it works without problems. Is the script importing well? (check how I import it here). Similarly, see if your browser has support for scripts enabled.
PS: Add a bit of CSS to the Body element. The code works in firefox (developer edition), but the default color of the font is white.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script src="time.js"> </script>
</body>
</html>
+ 8
Your code runs well as I tested it on Opera Mini browser, even with its reputation for having below average of good JavaScript implementation as a browser, just wanted to let you know...
+ 2
The code works fine in my browser. How are you runing it?
+ 2
Can you create your code in Code Playground and later attach it here?
+ 2
yes
+ 1
I write this code in <script> Tag