Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple way to display data in a .txt file on a webpage?

Tags:

html

iframe

Working on a project, one of the webpages will display a list of people (specifically, a list of people from a graduation class that haven't been located yet). Instead of manually updating these lists in tables which is a boneheaded Web 1.0 way of doing it, I'd like to take the submitted list of names, convert them to a simple .txt list, and then display that list on the webpage.

So far, the easist way to do this is to use an iframe element... only thing is, I cannot (or don't know how to) apply any text styling to the contents of the iframe. I've published a sample of what I've been able to accomplish here: http://dongarber.com/test//helpus-iframetest.html

The default font is courier, and the client probably ain't gonna be too keen on it. Is there a better way to do this, that's doesn't require ASP.NET or a database?

#list  p {     font: arial;     font-size: 14px; }  ...       <p>Help us locate all of our classmates from the High School class of 1961. If  you know&nbsp;where they live&nbsp;or their e-mail addresses contact the Reunion Committee.</p>     <p>&nbsp;</p>     <div id="list"><p><iframe src="missingmen.txt" width=200 height=400 frameborder=0 ></iframe></p></div>      </div> 
like image 471
DonG Avatar asked Jan 10 '11 00:01

DonG


People also ask

How do I read a text file in HTML?

Make sure you check the source of the document once it's loaded in the browser (all browsers let you do this, right-click "view page source" or similar). If you see the contents of version. txt anywhere in there, you're on the right track, you just need to move it into the body tag so that it will be rendered.


2 Answers

Easy way:

  • Rename missingmen.txt to missingmen.html.
  • Add a single line to the top of missingmen.html:
    <link href="txtstyle.css" rel="stylesheet" type="text/css" />
  • Create a file called txtstyle.css, and add to it a line like this:
    html, body {font-family:Helvetica, Arial, sans-serif}
like image 91
thirtydot Avatar answered Sep 30 '22 01:09

thirtydot


I find that if I try things that others say do not work, it's how I learn the most.

<p>&nbsp;</p> <p>README.txt</p> <p>&nbsp;</p> <div id="list">   <p><iframe src="README.txt" frameborder="0" height="400"       width="95%"></iframe></p> </div> 

This worked for me. I used the yellow background-color that I set in the stylesheet.

#list  p {     font: arial;     font-size: 14px;     background-color: yellow ; } 
like image 36
CLANofCIRE Avatar answered Sep 30 '22 01:09

CLANofCIRE