Also, hier der Code:
index.htm:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#text {
height:100px;
width: 300px;
border:1px solid black;
margin:auto;
overflow:auto;
}
</style>
<script type="text/javascript">
var request = false;
function setRequest()
{
request = new XMLHttpRequest();
if (!request)
{
alert("Fehler: Kann keine XMLHTTP-Instanz erzeugen");
return false;
}
else
{
request.open('post', 'myfile.txt', true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.send("");
request.onreadystatechange = interpretRequest;
}
}
function interpretRequest() {
switch (request.readyState)
{
case 4:
if (request.status == 200)
{
var content = request.responseText;
document.getElementById('text').innerHTML = content;
document.all.lastEntry.scrollIntoView(true);
window.setTimeout("setRequest()", 10000);
}
break;
default:
break;
}
}
setRequest();
</script>
</head>
<body>
<div id="text">Loading...</div>
</body>
</html>
myfile.txt:
a<br/>
b<br/>
c<br/>
d<br/>
e<br/>
f<br/>
g<br/>
h<br/>
i<br/>
j<br/>
k<br/>
l<br/>
m<br/>
n<br/>
o<br/>
<span id="lastEntry">p</span>
Es funktioniert nicht.