.ﺩﺮﮐ ﺍﺮﺟﺍ ﯽﻧﺎﻣﺯ ﯼﺎﻫ ﻩﺯﺎﺑ ﺭﺩ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
.ﯼﺪﻨﺑ ﻥﺎﻣﺯ ﯼﺎﻫﺩﺍﺪﯾﻭﺭ ﺪﻨﯾﻮﮔ ﯽﻣ ﻦﯾﺍ ﻪﺑ
1
2
3
4
5
6
7
8
9
10
11
12
|
.ﺪﻫﺩ ﯽﻣ ﺺﺨﺸﻣ ﯽﻧﺎﻣﺯ ﯼﺎﻫ ﻩﺯﺎﺑ ﺭﺩ ﺍﺭ ﺪﮐ ﯼﺍﺮﺟﺍ ﻥﺎﮑﻣﺍ .ﺪﻨﻣﺎﻧ ﯽﻣ ﯼﺪﻨﺑ ﻥﺎﻣﺯ ﯼﺎﻫﺩﺍﺪﯾﻭﺭ ﺍﺭ ﯽﻧﺎﻣﺯ ﯼﺎﻫ ﻩﺯﺎﺑ ﻦﯾﺍ :ﺯﺍ ﺪﻨﺗﺭﺎﺒﻋ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺎﺑ ﻩﺩﺎﻔﺘﺳﺍ ﯼﺍﺮﺑ ﯼﺪﯿﻠﮐ ﺵﻭﺭ ﻭﺩ .ﺖﺷﻮﻧ ﻩﺮﺠﻨﭘ ﺪﻧﻮﺸﯿﭘ ﻥﻭﺪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ .ﺩﻮﺷ ﺍﺮﺟﺍ ﺪﯾﺎﺑ ﻪﮐ ﺖﺳﺍ ﯽﻌﺑﺎﺗ ﺮﺘﻣﺍﺭﺎﭘ ﻦﯿﻟﻭﺍ .ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﺍﺮﺟﺍ ﺯﺍ ﻞﺒﻗ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ ﺩﺍﺪﻌﺗ ﻡﻭﺩ ﺮﺘﻣﺍﺭﺎﭘ :ﺪﻫﺩ ﯽﻣ ﺭﺍﺪﺸﻫ ﺍﺭ "Hello" ﻪﺤﻔﺻ ﻭ ﺪﯿﻨﮐ ﺮﺒﺻ ﻪﯿﻧﺎﺛ 3 .ﺪﯿﻨﮐ ﮏﯿﻠﮐ ﻪﻤﮐﺩ ﮏﯾ ﯼﻭﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺪﻨﮐ ﯽﻣ ﻒﻗﻮﺘﻣ ﺍﺭ ﻊﺑﺎﺗ ﯼﺍﺮﺟﺍ .ﺖﺷﻮﻧ ﻩﺮﺠﻨﭘ ﺪﻧﻮﺸﯿﭘ ﻥﻭﺪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯿﻐﺘﻣ ﺯﺍ .ﺪﯿﻨﮐ ﻒﻗﻮﺘﻣ ﺍﺭ ﺍﺮﺟﺍ :ﻩﺪﺷ ﻪﻓﺎﺿﺍ "ﻒﻗﻮﺗ" ﻪﻤﮐﺩ ﮏﯾ ﺎﺑ ﺎﻣﺍ ،ﻻﺎﺑ ﻝﺎﺜﻣ ﻥﺎﻤﻫ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺪﻨﮐ ﯽﻣ ﺭﺍﺮﮑﺗ ﻩﺩﺍﺩ ﺮﻫ ﺭﺩ ﺍﺭ ﻦﯿﻌﻣ ﻊﺑﺎﺗ ﮏﯾ .ﺖﺷﻮﻧ ﻩﺮﺠﻨﭘ ﺪﻧﻮﺸﯿﭘ ﻥﻭﺪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ .ﺩﻮﺷ ﺍﺮﺟﺍ ﺪﯾﺎﺑ ﻪﮐ ﺖﺳﺍ ﯽﻌﺑﺎﺗ ﺮﺘﻣﺍﺭﺎﭘ ﻦﯿﻟﻭﺍ ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﮏﯾ ﺮﻫ ﻦﯿﺑ ﯽﻧﺎﻣﺯ ﻪﻠﺻﺎﻓ ﻝﻮﻃ ﻡﻭﺩ ﺮﺘﻣﺍﺭﺎﭘ ﻝﺎﺘﯿﺠﯾﺩ ﮏﯾ ﺪﻨﻧﺎﻣ) ﺪﻨﮐ ﯽﻣ ﺍﺮﺟﺍ ﺭﺎﺑ ﮏﯾ ﻪﯿﻧﺎﺛ ﺮﻫ ﺍﺭ myTimer ﻡﺎﻧ ﻪﺑ ﯽﻌﺑﺎﺗ ﻝﺎﺜﻣ ﻦﯾﺍ :ﯽﻠﻌﻓ ﻥﺎﻣﺯ ﺶﯾﺎﻤﻧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ 1000 ﻪﯿﻧﺎﺛ ﮏﯾ ﺭﺩ .ﺪﻨﮐ ﯽﻣ ﻒﻗﻮﺘﻣ ﺍﺭ ﻊﺑﺎﺗ ﯼﺍﺮﺟﺍ .ﺖﺷﻮﻧ ﻩﺮﺠﻨﭘ ﺪﻧﻮﺸﯿﭘ ﻥﻭﺪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ :ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ :ﻢﯾﺍ ﻩﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺍﺭ "Stop time" ﻪﻤﮐﺩ ﺎﻣ ﺎﻣﺍ ،ﻻﺎﺑ ﻝﺎﺜﻣ ﺪﻨﻧﺎﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺮﮕﯾﺩ ﻩﺩﺎﺳ ﯼﺪﻨﺑ ﻥﺎﻣﺯ ﮏﯾ ﺖﺳﺍ ﻩﺪﺷ ﺩﺎﺠﯾﺍ ﯼﺪﻨﺑﻥﺎﻣﺯ ﺩﺍﺪﯾﻭﺭ ﮏﯾ ﺎﺑ ﻪﮐ ﯽﺘﻋﺎﺳwindow
setTimeout(function, milliseconds
)
ﺪﻨﮐ ﯽsetInterval(ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ ،ﻊﺑﺎﺗ
)
ﺪﻨﻧﺎﻤﻫ setsetTimeout()
ﻭ setInterval
.()setTimeout ﺪﺘﻣ
window.setTimeout(function, milliseconds);
window.setTimeout()
ﻝﺎﺜﻣ
<button onclick="setTimeout(myFunction, 3000)">Try it</button>
<script>
function myFunction() {
alert('Hello');
}
</script>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Timing</h2>
<p>Click "Try it". Wait 3 seconds, and the page will alert "Hello".</p>
<button onclick="setTimeout(myFunction, 3000);">Try it</button>
<script>
function myFunction() {
alert('Hello');
}
</script>
</body>
</html>
؟ﻢﯿﻨﮐ ﻒﻗﻮﺘﻣ ﺍﺭ ﻡﺍﺪﻋﺍ ﻪﻧﻮﮕﭼ
clearTimeout()
ﺵﻭﺭwindow.clearTimeout(timeoutVariable)
window.clearTimeout()
clearTimeout()
ﺵﻭﺭmyVar = setTimeout(function, milliseconds);
clearTimeout(myVar);
clearTimeout()
ﯽﻧﺍﻮﺧﺍﺮﻓ ﺎﺑ ﺪﯿﻧﺍﻮ ﻝﺎﺜﻣ
<button onclick="myVar = setTimeout(myFunction, 3000)">Try it</button>
<button onclick="clearTimeout(myVar)">Stop it</button>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Timing</h2>
<p>Click "Try it". Wait 3 seconds. The page will alert "Hello".</p>
<p>Click "Stop" to prevent the first function to execute.</p>
<p>(You must click "Stop" before the 3 seconds are up.)</p>
<button onclick="myVar = setTimeout(myFunction, 3000)">Try it</button>
<button onclick="clearTimeout(myVar)">Stop it</button>
<script>
function myFunction() {
alert("Hello");
}
</script>
</body>
</html>
.()setInterval ﺪﺘﻣ
setInterval()
window.setInterval(function, milliseconds);
window.setInterval()
ﻝﺎﺜﻣ
setInterval(myTimer, 1000);
function myTimer() {
const d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Timing</h2>
<p>A script on this page starts this clock:</p>
<p id="demo"></p>
<script>
setInterval(myTimer, 1000);
function myTimer() {
const d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
</script>
</body>
</html>
؟ﻢﯿﻨﮐ ﻒﻗﻮﺘﻣ ﺍﺭ ﻡﺍﺪﻋﺍ ﻪﻧﻮﮕﭼ
clearInterval()
ﺵﻭﺭwindow.clearInterval(timerVariable)
window.clearInterval()
setInterval()
ﺯﺍ ﻩﺪﺷ ﻩﺪﻧﺍﺩﺮﮔﺮﺑ ﺮﯿﻐﺘﻣlet myVar = setInterval(function, milliseconds);
clearInterval(myVar);
ﻝﺎﺜﻣ
<p id="demo"></p>
<button onclick="clearInterval(myVar)">Stop time</button>
<script>
let myVar = setInterval(myTimer, 1000);
function myTimer() {
const d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
</script>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Timing</h2>
<p>A script on this page starts this clock:</p>
<p id="demo"></p>
<button onclick="clearInterval(myVar)">Stop time</button>
<script>
let myVar = setInterval(myTimer ,1000);
function myTimer() {
const d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
</script>
</body>
</html>
ﺮﺘﺸﯿﺑ ﯼﺎﻫ ﻪﻧﻮﻤﻧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaSript setTimeout()</h2>
<p id="demo">I will display when two, four, and six seconds have passed.</p>
<script>
setTimeout(myTimeout1, 2000)
setTimeout(myTimeout2, 4000)
setTimeout(myTimeout3, 6000)
function myTimeout1() {
document.getElementById("demo").innerHTML = "2 seconds";
}
function myTimeout2() {
document.getElementById("demo").innerHTML = "4 seconds";
}
function myTimeout3() {
document.getElementById("demo").innerHTML = "6 seconds";
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body onload="startTime()">
<h2>JavaScript Clock</h2>
<div id="txt"></div>
<script>
function startTime() {
const today = new Date();
let h = today.getHours();
let m = today.getMinutes();
let s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML = h + ":" + m + ":" + s;
setTimeout(startTime, 1000);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
</body>
</html>