Created
July 18, 2010 19:33
-
-
Save velenux/480644 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Simple javascript timed output</title> | |
<script language="Javascript"> | |
var delay = 1000; // 1 second delay | |
function writeOut() { | |
// get content via xml http request or whatever | |
var out = getContent(); | |
// get our target div | |
t = document.getElementById('target'); | |
// set the target div content to the content itself | |
// PLUS a line break PLUS our output | |
t.innerHTML = t.innerHTML + '<br>' + out; | |
// call back itself in 1 sec | |
setTimeout('writeOut()', delay); | |
} | |
function getContent() { | |
// some meaningless content | |
return Math.floor(Math.random()*11); | |
} | |
</script> | |
</head> | |
<body onLoad="writeOut();"> | |
<div id="target"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment