Electronic clock on the site

Simple electronic watches that can be installed on the site.

I will give a very short css so that you will have freedom for creativity.

To make the clock work, add the onload = "digitalWatch ()" attribute to the body tag.

If the clock is only needed on a separate page, then all the code is placed in the body tag

Скрипт:


<script type="text/javascript">
function digitalWatch() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours < 10) hours = "0" + hours;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
document.getElementById("digital_watch").innerHTML = hours + ":" + minutes + ":" + seconds;
setTimeout("digitalWatch()", 1000);
}
</script">

CSS:


#digital_watch{
letter-spacing: 5px;
color: #777;
font-size: 30px;
border: 2px solid #777;
padding: 10px;
width: 160px;
box-shadow: 1px 1px 3px #BCCCCF,
-1px -1px 2px #BCCCCF;

HTML:


<body onload="digitalWatch()">
<p id="digital_watch"></p>
</body>

Code that can be copied, pasted into the editor and done with the design



<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Часы</title>
<head>
<script type="text/javascript">
function digitalWatch() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours < 10) hours = "0" + hours;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
document.getElementById("digital_watch").innerHTML = hours + ":" + minutes + ":" + seconds;
setTimeout("digitalWatch()", 1000);
}
</script">

<style>
#digital_watch{
letter-spacing: 5px;
color: #777;
font-size: 30px;
border: 2px solid #777;
padding: 10px;
width: 160px;
box-shadow: 1px 1px 3px #BCCCCF,
-1px -1px 2px #BCCCCF;
}
</style>
</head>

<body onload="digitalWatch()">
<p id="digital_watch"></p>
</body>
</html>

I wish you creative success.

This entry was posted in Free Scripts Ready Code. Bookmark the permalink.
А так же:

Leave a Reply

Your email address will not be published. Required fields are marked *