Javascript examples for Browser Object Model:Window setTimeout
Sleep certain seconds with setTimeout() method
<html> <head></head> <body> <script> var d = 120;/*w w w.j a v a 2 s. com*/ var start = new Date (); document.write(start + " : sleeping for " + d + " seconds"); </script> <div id="result"> <div> <script> function cb() { var now = new Date (); document.getElementById("result").innerHTML = "" + Date () + " : callback fired after " + (now.getTime() - start.getTime()) / 1000 + " seconds"; }; window.setTimeout(cb, d * 1000); </script> </div> </div> </body> </html>