JavaScript で setTimeout を使って定期的に処理を行なう方法
2010年9月 3日 14:04
JavaScript で、数秒おきとか数分おきに定期的に自動で処理を行なう方法の解説です。
ブラウザ上でタイマー的なことを実現したり、Ajax 非同期通信と平行してブラウザ上の何らかの値を監視したりするのにも使えます。
window.setTimeout() を使うと、指定した時間の後に処理を実行できるので、これを利用してループを行ないます。
// 最初の実行 TimerCount(); function TimerCount(){ // ここに定期的に行なう処理を書く // 1秒ごとに実行 window.setTimeout("TimerCount()",1000); }
setTimeout の書式は 「setTimeout(処理,待機する時間(1/1000秒単位))」となっているので、1秒ごとに実行する場合は 1000 を指定します。1分なら 60000 ですね。
- 現在位置
- TOP > Web制作技術 > JavaScript > JavaScript で setTimeout を使って定期的に処理を行なう方法
- 前のブログ記事
- Twitterビジネス活用の無料個別相談会を開催します【9/6(月)~9/10(金)】 [2010年9月 2日 14:27]
- 次のブログ記事
- .ftpaccess による FTP接続制限の設定方法 [2010年9月 4日 19:25]
トラックバック(2)
» JavaScript/setTimeout(PukiWiki Plus! (PukiWiki/TrackBack 0.3))のトラックバック
[2013年2月 1日 19:07]
http://www.abe-tatsuya.com/web_prog/javascript/settimeout.php 続きを読む
» JavaScript/Tips/定期的に処理させる方法(PukiWiki Plus! (PukiWiki/TrackBack 0.3))のトラックバック
[2013年2月 1日 19:09]
JavaScriptでsetTimeoutを使って定期的に処理を行う方法 http://www.abe-tatsuya.com/web_prog/java... 続きを読む
コメント(13)
wgrubd http://paydayloansnsa.com/ payday loans
jeunuov http://paydayloansukpla.co.uk/ click
fxofzg http://paydayloansmsa.com/ payday loans
mtfupe http://paydayloansitr.com/ money mutual
tizocf http://paydayloansbrb.com/ payday loans
tifsblyq http://paydayloansrnm.com/ payday loans
She was always carry always want L I just got cash territory Grange storage actual Art Walk talk 24 our 23 out searchers catch thank you so much I or cares shall try walk talk fast now as Hochstein just capture let me help she is always used to cost shit .
http://www.mentalfacts.com/
I shall touch Frank of don't use I what West watched staking out can get back hi check not somewhat at all in cast way hatch I stop cost or I not capped anyone else all cash that's why I'm ash bash Blackhawks coach kit watch information now care now .
http://www.mentalfitnesshomes.com/
We others or time sport loll of talking right absolutely that's great now you know you just addressed effect that you know a lot of women who are over 40 are going through a lot have mid-life issues whether it be divorced or family members passing away are just different changes such as that an you know next thing .
http://eye-fold.com/
you know there are you know a lot of issues that need to be dealt with physically so how important is really being honest with ourselves eyebrow you know the events that are going on and changes in the body as we age so that we can properly address them and be able to deal with them and move forward I'll chic chump for what host wasting .
http://eye-gather.com/
bumjtp http://orderviagrartb.com/ order viagra
After read a couple of the articles on your website these few days, and I truly like your style of blogging. I tag it to my favorites internet site list and will be checking back soon. Please check out my web site also and let me know what you think.
Its such as you scan my mind! You appear to understand such a lot concerning this, such as you wrote the book in it or one thing. i believe that you simply may do with some pics to drive the message home to a small degree, however apart from that, this is often nice web log. an excellent scan.
コメントする