<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…
<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....
-
Check this stackoverflow.com/a/22033170/2827823Asons– Asons2015年09月12日 21:06:50 +00:00Commented Sep 12, 2015 at 21:06
-
I tried it. Not working....not sure what's going on with it...Zheming Deng– Zheming Deng2015年09月12日 21:45:30 +00:00Commented Sep 12, 2015 at 21:45
-
If you read my link thoroughly (and understand it), you will see what/how to doAsons– Asons2015年09月12日 22:07:09 +00:00Commented 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.Zheming Deng– Zheming Deng2015年09月12日 22:36:56 +00:00Commented 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.Asons– Asons2015年09月13日 07:52:54 +00:00Commented Sep 13, 2015 at 7:52
1 Answer 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
answered Sep 12, 2015 at 21:08
Arsen
11k3 gold badges39 silver badges47 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Zheming Deng
I still didn't get it. Can you tell me more please?
default