I have an <object> tag like this:
<object id="text" data="file.txt"></object>
And I can get the element like this:
var text = document.getElementById("text");
Now, how do I get the content of the text file?
The purpose of this is to:
- avoid having to make an XMLHttpRequest;
- avoid having text data in the form of a constant in code;
- 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.
In the same fashion you can have an <img> or <audio> tag in the document and then access the image / sound, just for text files.
PS: I'm almost positive the <object> tag is not the ideal tag for this. This is just as far as I came trying to accomplish what I need.