Jump to content

Displaying a text (*.txt) file


Guest Toby DaBrit
 Share

Recommended Posts

Guest Toby DaBrit

I have a text file (data.txt), which I would like to display in the middle or an html page.I'm going little loopy trying to find an answer to this. :) I've tried the Java/XML example, which kept on throwing up errors for me.Load a textfile into a div element with XML HTTP (JavaScript)Can anyone give me some pointers on where I can find a solution?BTW After that I need to get the java to refresh, preferrably without having to use:<meta http-equiv="refresh" content="60">Thanks for reading.Toby

Link to comment
Share on other sites

What do you mean is wrong? What do you need with it?And you could use javascript to do it. Like this:<script type="text/javascript">function goThing(){window.location=window.location}t=set Timeout("goThing()","60")</script>

Link to comment
Share on other sites

if you really want to load an external text file inside your HTML, use javascript, but as Shinta suggested, PHP or ASP would be piece of cake...java script:1. save your 'data.txt' as 'data.js'2. inside your 'data.js':--------myVar = "put your data here, and, if necessary, escape Toby's strings like \"this\" \"because\" \"you\" \"may\" \"like\" \"quoting\" \"everything\"";--------(i exagereted because i had fu**** hard time scripting with javascript in the beginning without knowing about escaping strings, and no one needs to go through i went... [+s everywhere...])3. inside your html (where u want your data to be loaded:--------<script language="javascript" src="data.js">document.write(myVar);</script>--------With PHP simple (if your server runs PHP):<?include('data.txt');?>inside ur html page...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...