Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I'm not sure if the reason I'm having trouble with this is because it looks awfully like malicious activity or not. What I'm attempting to do is make my life a little less terrible with a piece of very inflexible and outdated web-based software.

Basically, there's a block of HTML that I can edit from within the software (it's inserted into a td element), and I want to have the content of that block come from a plaintext file on my local drive, being synced to the cloud with Dropbox.

It is possible to do something like this:


With the output being <td>[contentsof_file.txt]</td>?

share|improve this question
Would <iframe> work? You can do what you want with javascript, but it's not a simple, single function. – Darth Android Aug 26 '13 at 16:06
I was hoping not to use an iframe since it's much less elegant, but I'm somehow not able to get that to work either. – NReilingh Aug 26 '13 at 16:09
XSS is prevented by most browser JavaScript implementations. – Synetech Dec 31 '13 at 5:53
@Synetech Yes, this was my issue in testing, since the browser realized it was loading the same code being submitted in the previous page load. But, all the browsers I've tested have been okay loading a .js file from a remote server as long as everything is under SSL. – NReilingh Dec 31 '13 at 5:55

You can accomplish this with JQuery. You'll want to have a way you can lookup your td, like giving it an id:

<td id="insertTextHere">
share|improve this answer
up vote 0 down vote accepted

Rather than load a remote plaintext file, it turned out to be much easier to make the remote file a JavaScript "wrapper" that had the plaintext inlined using a rather-hackish "multiline text variable":


var myString = function(){/*

Editable plaintext or whatever goes here!
Multiline, too!

document.getElementById('content').innerHTML = myString;

The last line is what does all the work; it's simple enough that jQuery is overkill unless you run into insurmountable portability issues.

In the originating page (the block of HTML that is only editable manually), all you then need is:

<div id="content"></div>
<script src="https://dropbox/link/to/remote_editable_file.js" type="text/javascript"></script>
share|improve this answer
The last line does nothing more than to assign the contents of the specified element. Your answer is confusing because you said you wanted the contents of the file to be inserted, but nowhere in it have you specified a URL. Where are the contents of the file coming from? ಠ_ఠ Unless I’ve suddenly lost all knowledge of computers, I don’t see how your answer could possibly accomplish what you had asked. – Synetech Dec 31 '13 at 5:57
@Synetech Clarified. – NReilingh Dec 31 '13 at 6:00
…it was loading the same code being submitted in the previous page load… In the originating page… Actually it’s more confusing now. What/where is this other page? I still don’t see where the .txt file or its contents come in. – Synetech Dec 31 '13 at 6:03
@Synetech Sorry; edited again. Give it one more try? – NReilingh Dec 31 '13 at 6:11
So in other words, you gave up trying to load an external file and just put it directly in the .js file? In that case, why bother with a separate file? Why not just put it directly in the .html file? Is it something that would be used in multiple files? – Synetech Dec 31 '13 at 6:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .