-1
<html>
<head>
<title>My first styled page</title>
</head> 
<body>

<script> 
var reader = new FileReader();
reader.onload = function(){
var text = reader.result;
document.querySelector('body').append(text);
};
reader.readAsText(README, "us-ascii");
</script>

<!-- Site navigation menu -->
<ul class="navbar">
<li><a href="alamode-fetch">Alamode</a>
<li><a href="README">Readme</a>
<li><a href="town.html">My town</a>
<li><a href="links.html">Links</a>
</ul>

<!-- Main content -->
<h1>My first styled page</h1>
<p>Welcome to my styled page!
<p>It lacks images, but at least it has style.And it has links, even if they       don't go anywhere&hellip;
<p>There should be more here, but I don't know what yet.
<!-- Sign and date the page, it's only polite! -->
<address>Made 5 April 2004<br> 
by myself.
</address>
</body>
</html>

Above is my html file. I was trying to reading the local file named as README. When I execute my html file, looks like there is nothing happened with my javascript. And I found that in the firefox, it reminds that README is not defined. I have stuck on it for whole day....

1 Answers1

-1

The problem is README. Javascript expect README will be a variable but you don't define it.

Check out https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText

Arsen
  • 10,815
  • 2
  • 34
  • 46