title: Reading/Writing files in JavaScript
body: <p>I'm trying to make a web app that will read in a server-side CSV file and display it in a neat, browsable format. The catch is that I want to do it in naked JS/CSS3/HTML5. <strong>Is there any way to read and write server-side files with naked JS/CSS3/HTML5?</strong> I obviously want this to be OS/browser  independent.</p>
  
  <h2>What I've tried</h2>
  
  <hr>
  
  <p>I <em>have</em> tried implementing some code I found online (a few sites reference it). Below is what I tried while testing: (I just want the test to show the contents of the webpage, itself, in the webpage)</p>
  
  <p><a href="http://s.supuhstar.operaunite.com/s/content/JS/scripttest.htm" rel="nofollow"><code>scriptTest.htm</code></a>:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="readIt.JS"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;button onclick="return readIt();"&gt;Show the code of the page&lt;/button&gt;
  &lt;div id="readItOutput"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="http://s.supuhstar.operaunite.com/s/content/JS/readIt.JS" rel="nofollow"><code>readIt.JS</code></a>:</p>
  
  <pre><code>function readIt()
  {
      file = fopen(getScriptPath("scriptTest.htm"), 0);
      file_length = flength(file);
      content = fread(file, file_length);
      document.getElementById("readIt").innerText = content;
  }
  </code></pre>
  
  <p>However, whenever I run it, under Opera and Chrome, it throws the following:</p>
  
  <p><strong>Opera:</strong></p>
  
  <pre><code>Uncaught exception: ReferenceError: Undefined variable: fopen
  Error thrown at line 3, column 1 in readIt() in http://s.supuhstar.operaunite.com/s/content/JS/readIt.JS:
      file = fopen(getScriptPath("scriptTest.htm"), 0);
  called from line 1, column 0 in &lt;anonymous function&gt;(event) in http://s.supuhstar.operaunite.com/s/content/JS/scripttest.htm:
      return readIt();
  </code></pre>
  
  <p><strong>Chrome:</strong></p>
  
  <pre><code>Uncaught ReferenceError: getScriptPath is not defined
  readItreadIt.JS:3
  (anonymous function)scripttest.htm:6
  onclick
  </code></pre>