opening a text document to show a .txt file through a browser link

Sam Hughes me at privacy.net
Sun Dec 29 08:39:00 EST 2002


"Ole Jensen" <ole_jensen at dbmail.dk> wrote in
news:hcrP9.30944$Y2.1113 at news2.bredband.com: 

> INTRODUCTION to my question
> ---------------------------------------------------------
> A slight introduction, might be required: I have for a long time now
> wanted to learn how to program I have also for equally long time
> wanted to gain some skills in making internet sites. Unfortunatly I
> have not known what to program nor known what to right about on a
> internet site. Until recently I got the freightning idea of doing
> *both* ---------------------------------------------------------

Making Web sites is _not_ programming.  Programming happens when you give a 
list of instructions that are to be executed.  Making web sites involves 
using markup to describe text and images.  Web sites do not give browsers 
instructions, they give browsers information.  A <p> tag doesn't say 
"Render this like a paragraph and add the default margin between it and 
other paragraphs," it says "This here is a paragraph."

You don't control the user's browser.  You can't.  The browser is in 
control.

> Question:
> Example: when you want to check someone's .css file then you type in
> the url of the .css files location, and a text editor appears with the
> style codes within it. (everyone knows this right!)

Well, maybe.  Maybe the browser would display the CSS file in the browser 
window.  Maybe it would just offer a Download and Save As... dialogue box.

> now What I would like to do is to have the same effect with text file
> that I have *linked* to.

<a href="file.txt">A link :)</a>

It's up to the browser on what to do with the link.

> 
> I get the effect I want if I type in the url of the txt file. but I
> dont want to type in the url I just want click the link and have a
> text editor showing me the code, not the browser as it is now!
> 
> I have tried (rather optimitically) with <a type=text/plain
> href="LINK"> 

Well maybe if href equalled something like "file.txt" or whatever it was 
named, it would work better. :)

> but no luck.
> 
> Also if it is possible I would like to make annother link that opens
> the same file in a specífic program (which I expect most of my viewers
> to have installed) how can this be done (if possible)

You can only link to the files.  When you link to a file, the browser 
decides what to do with it.  You cannot control that.

> for currious people the (tempory) link is:
> D:\Programmer\frontpage2K\Sites\Learning to program\programs.htm

That's a "link" that only works on your computer.  Nobody else has a "D" 
drive with that path.  It is totally useless to anybody else.  Do you 
expect me to be able to hack into your computer?

I'm really not sure why this is posted to comp.lang.python, either.



More information about the Python-list mailing list