JavaScript ile Saat Yapımı

S

Shiva

Veteran
Joined
Jul 31, 2019
Messages
4,067
Reaction score
13,322
Location
Berlin
JavaScript kullanarak Dijital Saat veya JavaScript’te Basit Dijital Saat Oluşturma

Herhangi bir Web sayfasına yerleştirebileceğiniz basit bir gerçek zamanlı saat yapmak için JavaScript’in Date nesnesini ve Window.setInterval yöntemini kullanın. Yol boyunca, DOM’daki metin düğümlerine ve bir onLoad olay işleyicisinin nasıl ayarlanacağına göz atın.


dijital-saat-yap%C4%B1m%C4%B1.png


JavaScript Kodu:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html>
<head>
<title>JavaScript Dijital Saat</title>
<link href="https://fonts.googleapis.com/css?family=Orbitron" rel="stylesheet" type="text/css"/>

<style>
.tabBlok
{
background-color:#57574f;
border:solid 0px #FFA54F;
border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px;
max-width:200px;
width:100%;
overflow:hidden;
display:block;
}
.dijitalSaat
{
vertical-align:middle;
font-family:Orbitron;
font-size:40px;
font-weight:normal;
color:#FFF;
padding:0 10px;
}
.saat
{
vertical-align:middle;
font-family:Orbitron;
font-size:20px;
font-weight:normal;
color:#FFF;
}
.zemin{
background-color:#F3F3F3;
max-width:220px;
width:100%;
margin:0 auto;
padding:20px;
}
</style>
</head>

<body onload="dijitalSaat();">
<div class="zemin">

<table class="tabBlok" align="center" cellspacing="0" cellpadding="0" border="0">
<tr><td class="dijitalSaat" id="dt"></td>
<td>
<table cellpadding="0" cellspacing="0" border="0">

<tr><td class="saat" id="dt_saat">?</td></tr>

<!-- SHOWING SECONDS. -->
<tr><td class="saat" id="dt_saniye"></td></tr>
</table>
</td>
</tr>
</table>
</div>
</body>

<script>
// tarih oluşturma fonksiyonu
function dijitalSaat() {
var dt = new Date(); // DATE() ile yeni bir tarih nesnesi oluşturuldu.
var saat = dt.getHours();
var dakika = dt.getMinutes();
var saniye = dt.getSeconds();

dakika = Tik(dakika);
saniye = Tik(saniye);

document.getElementById('dt').innerHTML = saat + ":" + dakika;
document.getElementById('dt_saniye').innerHTML = saniye;

if (saat > 12) {
document.getElementById('dt_saat').innerHTML = '?';
}
else {
document.getElementById('dc_hour').innerHTML = '?';
}

// her 1 saniyede bir yenileme yapılıyor.
var time
time = setInterval('dijitalSaat()', 1000);
}

function Tik(tikDegeri) {
if (tikDegeri < 10) {
tikDegeri = "0" + tikDegeri;
}
return tikDegeri;
}
</script>
</html>
 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Tema düzenleyici

Top Bottom