Forum Moderators: open

Message Too Old, No Replies

How do you tell IE that you want .txt a text file?

It shows it as links, not the HTML code.

         

Jesse_Smith

12:27 am on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got a database of links in .txt files but IE thinks there HTML files and loads it as links, instead of showing the URL HTML codes. How do you make it so a .txt file will show the HTML link codes instead of HTML links. Only if there is a certian ammount of text before the links does it view the file as text.

I try

<A HREF="http://www.urlwidget37578.com">

But then it shows it as text, with the & LT; and & GT; instead of < and >.

Birdman

12:32 am on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could put them in a textarea. Sorry if I am missing the point.

Chris_R

12:35 am on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah. I am not sure exactly what you are trying to do.
I have run into things like this before - and by using textpad, excel, notpad, and some other stuff - I am usually able to get what I want.

SinclairUser

1:32 am on May 23, 2003 (gmt 0)

10+ Year Member



Wrap them text in <pre>your text</pre> tags.

Jesse_Smith

4:28 am on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to make Internet Explorer view the file the way a .txt file is supposed to, as a text file showing the HTML code of every link, not as a HTML file showing it as links. When it's just links, it's too stupid to know it's a text file and not a HTML file. Is there an easior way to do that than having to turn all the files in to HTML and use &LT; and &GT;? I want the .txt file to look like

<A HREF="http://www.urlwidget37578.com">name</a>
<A HREF="http://www.urlwidget37578.com">name</a>
<A HREF="http://www.urlwidget37578.com">name</a>

and not

name [urlwidget37578.com] name [urlwidget37578.com] name [urlwidget37578.com] name [urlwidget37578.com]

If I use &LT; and &GT; then it changes from links to the text showing LT; and &GT; , so that doesn't work.

:::You could put them in a textarea.

Now that looks like a good idea, in a form box.

keyplyr

6:31 am on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



IE renders my .txt files as text files just fine. I'm currently using 6.0, but they rendered OK in 5.5 as well. Must be how you are accessing the .txt file or how the .txt file is being served.

choster

1:58 pm on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried escaping the ampersands themselves? IOW


&amp;lt;a href="http://www.urlwidget37578.com/"&amp;gt;

universalis

6:38 pm on May 23, 2003 (gmt 0)

10+ Year Member



Birdman has the right answer: use a textarea and include the text file. Here's a simplified but working example with php:

File 1: "url.txt"

<a href="widget.htm">Widget</a>
<a href="widget.htm">Widget</a>
<a href="widget.htm">Widget</a>

File 2: "urllist.php"


<?php header("Content-type: text/html");?>
<html><head><title></title>
<style type="text/css">
textarea {border:none;}
</style>
</head><body>
<h1>test txt file insert</h1>
<textarea cols="100" rows="3"><?php readfile("url.txt")?></textarea>
</body></html>

The CSS removes the border, making the textarea seamless, and you need to set the number of rows in the textarea to the number of entries in the "url.txt" file to avoid getting a scrollbar (you can use CSS to banish the overflow to make sure the scrollbar never appears, but that'd get in the way of this example). Of course, there may be a simpler way...

keyplyr

12:31 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




...use a textarea... - universalis

textarea needs to be written in HTML.

I got a database of links in .txt files - Jesse_Smith

These are .txt files no matter how IE is misinterpreting them. So using textarea, while a possible hack, is not addressing the real issue: Why is IE not reading the file correctly?

ShawnR

6:27 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"...IE renders my .txt files as text files just fine. I'm currently using 6.0, but they rendered OK in 5.5 as well. Must be how you are accessing the .txt file or how the .txt file is being served..."

If you access the .txt file straight off your hard drive, IE reads it correctly as text. If you have it served through a webserver IE gets confused sometimes. (i.e. it gets confused when there is an <a> tag in the file, but not when there is &lt;a). From what I can see this happens even though the webserver might be configured correctly to serve .txt files as mime type = "text/plain"

If you have access to php then universalis' suggestion means you don't have to make changes to the text files. If you don't, an alternative solution to the textarea one is to wrap the contents of the file around an html framework. Then you will be able to use the &lt;.

i.e.

<!DOCTYPE HTML....>
<html>
<head>
</head>
<body>
&lt;A HREF="http://www.urlwidget37578.com">name&lt;/a>
&lt;A HREF="http://www.urlwidget37578.com">name&lt;/a>
&lt;A HREF="http://www.urlwidget37578.com">name&lt;/a>
</body>
<html>

keyplyr, what do you mean by "textarea needs to be written in HTML"?

Shawn

keyplyr

6:52 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have it served through a webserver IE gets confused sometimes. - ShawnR

I can only speak from my experience. I serve a couple dozen .txt files with <a> tags and never has IE confused any of them as HTML files. In 6 years, never have I received feedback that anyone else has either.

Do the pages in which the files are accessed validate? Are full DTD with W3C URI used, or are you forcing IE to render in quirks mode?

ShawnR

7:05 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>>"...Are full DTD with W3C URI used..."

No, I mean IE gets confused when presented with a straight text file with no doctype declaration, but with the webserver configured to serve it as mime type "text/plain". i.e. just a straight forward text file, not ammended for serving to the web. I respect your 6 yrs experience, but I can and have reproduced Jesse_Smith's symptoms only half an hour ago. As I said, IE only gets confused sometimes (i.e. when the contents of the text file look like html, such as when it contains an <a> tag), which may explain why you have not seen the problem before.

What do you mean by "textarea needs to be written in HTML"? Am I missing something?

Shawn

keyplyr

7:29 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




What do you mean by "textarea needs to be written in HTML"? - ShawnR

I meant that if the textarea code is rendered from a .txt file, it would just show up as code, not as an actual textarea... as all HTML tags would on a .txt file. I say this because, once again, I have never experienced the quirks that you two seem to be.

I still think that this malady is the result of IE running in quirks mode because of some non-standard code, page, PHP or whatever path the webmaster is using to access the .txt file.

Good luck

rainborick

2:26 pm on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Isn't this more likely to be a server issue? I wonder if Jesse's server is sending "Content-type: text/html" for the text file in question, making MSIE treat it as an HTML file.

Jesse_Smith

5:11 pm on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:::I wonder if Jesse's server is sending "Content-type: text/html" for the text file in question, making MSIE treat it as an HTML file.

How do I find out if it's that? If it has some non-html stuff before the links, then it shows up as text instead of HTML.

I just turned it in to .shtml and used

&LT;A HREF="http://www.urlwidget37578.com"&GT;blah&LT;/a&GT;
for every link.

rainborick

6:59 pm on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Load the .txt file into your browser from your website using "http://www.yoursite.com/thefile.txt". If you're using Internet Explorer, select Properties from the File menu. If you're using Netscape Navigator, select Page Info from the View menu. These commands will bring up a display that will tell you what kind of file the browser thinks it is displaying. If it says "Hypertext document" or "HTML document", it thinks it has a webpage, but it should just say it has a "text" file. And the reason the browser would think its a webpage could be because of the server's settings. I'm using all kinds of fudge words here because it would be pretty unusual for a server to do this, especially if the file name ends in ".txt".

If you're hosted on an Apache-based server you can fix this yourself, but I need to look up the details. If you're hosted on a system that uses a different server software package, you'll have to contact your hosting service's tech support. But try my little experiment and see what happens first.

g1smd

7:49 pm on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You may need the & to be done as &amp; instead.

ShawnR

5:05 am on May 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>>"...And the reason the browser would think its a webpage could be because of the server's settings..."

>>>"... wonder if Jesse's server is sending "Content-type: text/html" for the text file in question, making MSIE treat it as an HTML file..."

Don't know about Jesse, but in my case the server is configured correctly, and other browsers recognise it as text. See msg#10 & msg#12.

Copy; paste into text file; save as test.txt in your favourite webserver's web pages directory; point IE browser to [localhost...] Hey, what do you know!

From what I can see this is an IE bug. I don't think its a webserver problem... I could be wrong...

universalis

11:46 am on May 26, 2003 (gmt 0)

10+ Year Member



It appears that I completely misunderstood the problem in my previous reply - so I'll try again, and if I'm wrong again, I'll just go and crawl back under a rock...!

I think I understand the problem. As always with Microsoft, "its not a bug, it's a feature!" IE4+ uses "MIME type detection" to work out how a document should be served. It does look at the MIME type given by the server, but the MIME type

text/plain
is considered as "ambiguous", so the detection algorithm kicks in. Seeing as your text file contains HTML, IE reckons that it should have been served as
text/html
. This, as you can see, is stupid. Check out this article which details the bug^h^h^h feature:

[msdn.microsoft.com...]

Hope this answer is more useful...!

ShawnR

12:05 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, universalis. That fits with the symptoms I see. Certainly no need to crawl behind a rock!

I must take you to task on one issue, however: I think your previous post was equally helpful. It presented a good workaround, even though the root cause of the problem was not yet clear. ;) Even now that the problem is understood, your post is still probably the best solution if php is available on the server.

Shawn

universalis

12:40 pm on May 26, 2003 (gmt 0)

10+ Year Member



Thanks, universalis. That fits with the symptoms I see. Certainly no need to crawl behind a rock!

Feeling all warm and fuzzy inside :D

I think your previous post was equally helpful. It presented a good workaround ... probably the best solution if php is available on the server.

Of course for my original reply, you can easily replace PHP with ASP or Coldfusion, or just do an include virtual if you only have bog-standard SSI. If you don't have PHP, ASP, Coldfusion or SSI, then change hosts!