I have a small Javascript, which is supposed to read the content of a local text file and display it on the browsers screen. It works on windows 7 with a current firefox, but it does not work on fedroa 20 with a current firefox or chrome. Here is the code:
<h1>View file content</h1>
<script>
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
alert(allText);
}
}
}
rawFile.send(null);
}
function read_status()
{
readTextFile('file:///tmp/status.txt');
}
</script>
<input id="clickMe" type="button" value="Current status" onclick="read_status(); " />
Why is this? How can I fix it?