![]() |
show a txt-file in Browser
Hello,
i want to link to mytext.txt, that looks something like: this;info;is;in;the;first;line this;comes;in;second;;; this;is;third;;;; But browsers dont understand the newline, so everything is in one line. I can't add <br>-Tags because the file is also needed to import into excel as comma-separated list. Are there any ideas for that? Thanks a lot for any help, Martin Nadoll |
Re: show a txt-file in Browser
Martin Nadoll wrote:
> i want to link to mytext.txt, that looks something like: > > this;info;is;in;the;first;line > this;comes;in;second;;; > this;is;third;;;; > > But browsers dont understand the newline, so everything is in one line. > I can't add <br>-Tags because the file is also needed to import into excel > as comma-separated list. > > Are there any ideas for that? Hmm... browsers should usually display .txt files 'as is'. Perhaps there's HTML in the .txt file, and the browser thinks it's HTML? Or perhaps the server doesn't send the correct MIME type? However, if you're importing/including this text in a HTML file, you could use either the PRE element <http://www.w3.org/TR/html4/struct/text.html#edef-PRE>, or the CSS white-space property, <http://www.w3.org/TR/CSS2/text.html#propdef-white-space> Matthias |
Re: show a txt-file in Browser
"Martin Nadoll" <martin@nadoll.de> wrote:
> i want to link to mytext.txt, that looks something like: > > this;info;is;in;the;first;line > this;comes;in;second;;; > this;is;third;;;; Looks a bit odd. But what's the URL? Note that the URL is essential, not the content only, since the URL reveals what the server announces about the Internet media type. > But browsers dont understand the newline, so everything is in one > line. Which newline? You _might_ have a problem with newline presentation convention in a plain text file (CR vs. LF vs. CR LF). > I can't add <br>-Tags because the file is also needed to > import into excel as comma-separated list. Of course you cannot use HTML markup in a plain text file - any correctly behaving browser will treat is plain data. But how come you refer to a comma-separated list? The character ";" is a semicolon in my book. I would suggest that you use either comma-separated list or tab- separated list and announce the media type appropriately. Specifically I would recommend tab-separated, for reasons explained at http://www.cs.tut.fi/~jkorpela/TSV.html Though ideally you should convert the data to a simple HTML table and make it available in both formats, via separate links (or even insert the HTML format into a normal HTML page). -- Yucca, http://www.cs.tut.fi/~jkorpela/ Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html |
Re: show a txt-file in Browser
Jukka K. Korpela wrote:
> http://www.cs.tut.fi/~jkorpela/TSV.html The table about 80% of the way down the page is screwy. Most of the rows don't begin with <tr>. -- Toby A Inkster BSc (Hons) ARCS Contact Me - http://www.goddamn.co.uk/tobyink/?id=132 |
Re: show a txt-file in Browser
Toby A Inkster <UseTheAddressInMySig@deadspam.com> wrote:
>> http://www.cs.tut.fi/~jkorpela/TSV.html > > The table about 80% of the way down the page is screwy. Most of the > rows don't begin with <tr>. Oops, thanks. The markup was _bad_. Fixed now. -- Yucca, http://www.cs.tut.fi/~jkorpela/ Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html |
Use <PRE> tag.
Put the text you read from the file in <PRE> tag.
Code:
document.getElementById('divlog').innerHTML = "<pre>"+http.responseText+"</pre>";Code:
<html>Quote:
|
| All times are GMT. The time now is 12:42 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.