Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Forked from anonymous/jsbin.kizav.html
Created March 16, 2014 08:23
Show Gist options
  • Save tenntenn/9580092 to your computer and use it in GitHub Desktop.
Save tenntenn/9580092 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
var TIMEOUT = 1* 1000;
setTimeout(function() {
if (document.readyState === 'complete') {
return;
}
alert('timeout!');
}, TIMEOUT);
document.addEventListener('readystatechange', function() {
console.log(document.readyState);
}, false);
</script>
</head>
<body>
<script>
console.log('start');
var STOP = 5 * 1000;
var before = new Date().getTime();
while(true) {
if (new Date().getTime() - before > STOP) {
break;
}
}
console.log('done');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment