8
11

More than 5 years have passed since last update.

数秒待ってから処理をする

Posted at

非同期通信をするときなどにsetTimeout()ってたまに使ってます.

setTimeout(function(){
    //処理を記述
},/*待つ秒数*/);

通常のJSで10秒待ってからリダイレクト

setTimeout(function(){
    location.href="/";
},10000);

node.jsで30秒待ってからリダイレクト

setTimeout(function(){
    res.redirect('/');
},30000);
8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11