title: Access <object> data with JavaScript
body: <p>I have an <code>&lt;object&gt;</code> tag like this:</p>
  
  <pre><code>&lt;object id="text" data="file.txt"&gt;&lt;/object&gt;
  </code></pre>
  
  <p>And I can get the element like this:</p>
  
  <pre><code>var text = document.getElementById("text");
  </code></pre>
  
  <p>Now, how do I get the content of the text file?</p>
  
  <p>The purpose of this is to:</p>
  
  <ol>
  <li>avoid having to make an XMLHttpRequest;</li>
  <li>avoid having text data in the form of a constant in code;</li>
  <li>keep a simple plaintext file in it's original form, without JSON or special formatting, to be accessed by code and become a string variable.</li>
  </ol>
  
  <p>In the same fashion you can have an <code>&lt;img&gt;</code> or <code>&lt;audio&gt;</code> tag in the document and then access the image / sound, just for text files.</p>
  
  <p>PS: I'm almost positive the <code>&lt;object&gt;</code> tag is not the ideal tag for this. This is just as far as I came trying to accomplish what I need.</p>