Forum Home
Press F1
 
Thread ID: 84490 2007-11-07 20:15:00 inserting a txt file into an html document? Jimmy D (2061) Press F1
Post ID Timestamp Content User
609204 2007-11-07 20:15:00 Hi,
I have an html document and i'd like to insert words from a txt file into a paragraph in the document. e.g/

htmldoc
<p> text from txt file </p>

is there a way to do this? have tried google but nothing really.

Regards,
James
Jimmy D (2061)
609205 2007-11-07 20:20:00 Just copy and paste. Greg (193)
609206 2007-11-07 20:57:00 but i want it to be linked so i can changed the txt file independent of the html file Jimmy D (2061)
609207 2007-11-07 21:00:00 not sure how to do it. but id be guessing you would have to use something like php to get that to work. or javascript. don't know as don't know either language. Cho (12330)
609208 2007-11-07 21:06:00 <a href="mytextfile.txt">READ my Text File</a>
The <a href="mytextfile.txt"> is the reference, followed by what you want displayed on the page, followed by a closing </a>


Using <p> la de da </p> Is just inserting la de da then a new paragraph. You don't actually require a closing </p> for paragraph it is optional.
Bantu (52)
609209 2007-11-07 21:47:00 Thanks Bantu. not exactly what i was looking for but helpful nonetheless :)
perhaps there is javascript that will do this?
Jimmy D (2061)
609210 2007-11-08 00:33:00 I'd steer clear of javascript for this - the only way you can do it with Javacsript is with XMLHTTPRequest, and I doubt you want the hassle (and a lot of people disable javascript anyway). The easiest way would be to just stick the text file in an iframe:
<iframe src="example.com sense? Note that you will probably need to apply styles to the iframe, it'll be damn ugly and probably the wrong size otherwise.
Erayd (23)
609211 2007-11-08 20:53:00 Use the <pre> tag to give preformatted text including all your newlines. You need to paste the text document inside <pre> and </pre> to make it preserve all the newlines, etc. It will also preserve whitespace so be careful! TGoddard (7263)
1