Javascript examples for Browser Object Model:Window setTimeout
Test HTML5 performance with setTimeout()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script type="text/javascript"> var timestamp = (new Date()).getTime(); function run() {//from w w w .j a va 2 s . c o m var now = (new Date()).getTime(); if( now - timestamp >= 1000 ) { console.log( 'tick' ); timestamp = now; } setTimeout(run, 10); } run(); </script> </body> </html>