3

I want to show txt files in HTML files. I find a simple way that is to use iframe tag of html

<iframe src="test.txt" style="width:100%; height:100%;" frameborder="0" scrolling="auto"/>

But it's not friendly to user. Is there any other better ways.

Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
Johnson
  • 31
  • 2
  • What does it look like? do you have a live example? – Kees Sonnema Jun 14 '13 at 08:13
  • 2
    I would do this in a JavaScript script like presented at http://stackoverflow.com/questions/13709482/how-to-read-text-file-in-javascript. – Tony Stark Jun 14 '13 at 08:13
  • You could create a css and format 'txt text' there (font, colors, etc) to make it look better. Or if you have a different issue, +1 to @KeesSonnema –  Jun 14 '13 at 08:14
  • Do you want to how to format the text file or how to correctly output/write a text file to the html document? – Andre Jun 14 '13 at 08:31

1 Answers1

1

several options: - javascript/ajax - php

this thread has some good suggestions: http://www.hotscripts.com/forums/html-xhtml-xml/53593-how-display-text-file-using-php-html.html

Ruben Verschueren
  • 822
  • 13
  • 28
  • Yes, we can use javascript or ajax. But there is a problem. ajax can get the txt content but all the contents will show in one line instead of multiple lines. It's hard for me to split it. What do you think? – Johnson Jun 15 '13 at 00:52
  • It depends if you don't have any clear line endings what you could do is split on periods, exlamation marks etc. so that each sentence starts on a new line. A better way would be to decide a number of characters for each line. Then you just look for the closest space character and split on that. – Ruben Verschueren Jun 15 '13 at 18:40