I have the following code which allows a user to pick a text file and then it loads the contents into the PRE tag below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Load text file</title>
<script type="text/javascript">
function readText(that){
if(that.files && that.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var contents = e.target.result;//.replace("\r\n","<br/>");
contents = contents.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
document.getElementById('board').innerHTML= contents;
};//end onload()
reader.readAsText(that.files[0]);
}//end if html5 filelist support
}
</script>
</head>
<body>
<input type="file" onchange='readText(this)' /> <hr />
<pre id="board" contenteditable = "true">
This is where the text from the chosen text file will be loaded.
</pre>
</body>
</html>
Is it possible to read the contents of the chosen file every 10 seconds?
For example the user chooses the text file (once). Then the code loops and re-reads the contents and updates the PRE tag with any changes that may have been made to the text file.
I am working locally so any server scripting is not possible.
I have a feeling the solution might involve a SETINTERVAL?
Thanks in davance.