Guest Toby DaBrit Posted January 7, 2006 Share Posted January 7, 2006 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 More sharing options...
Chocolate570 Posted January 7, 2006 Share Posted January 7, 2006 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 More sharing options...
~Shinta Posted January 9, 2006 Share Posted January 9, 2006 Use PHP or SSI includes. Link to comment Share on other sites More sharing options...
zanfranceschi Posted January 10, 2006 Share Posted January 10, 2006 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 More sharing options...
playmenow Posted January 17, 2006 Share Posted January 17, 2006 <script language="javascript" src="data.js">document.write(myVar);</script>There is no attribute "language".....the NEW one is: type="text/javascript"So, if you try it in XHTML (& even HTML) & try to validate it, then you will get a warning: There is no such attribute.so........ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now