-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....

5
  • Check this stackoverflow.com/a/22033170/2827823 Commented Sep 12, 2015 at 21:06
  • I tried it. Not working....not sure what's going on with it... Commented Sep 12, 2015 at 21:45
  • If you read my link thoroughly (and understand it), you will see what/how to do Commented Sep 12, 2015 at 22:07
  • Yes, I read it carefully and tried. There is no error in Firefox. But still nothing different. What I am concerning is that maybe either my Firefox or Linux has issue. Commented Sep 12, 2015 at 22:36
  • That might be, so I guess next step for you is to debug every line of your js code and check the relevance of each variable/value. Commented Sep 13, 2015 at 7:52

1 Answer 1

-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

Sign up to request clarification or add additional context in comments.

1 Comment

I still didn't get it. Can you tell me more please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.