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

Mike Meyer mwm at mired.org
Mon Dec 30 01:23:00 EST 2002


"Ole Jensen" <ole_jensen at dbmail.dk> writes:

> So are you suggesting that I keep the link as is, and make the users
> copy'n'paste the contents from their internet browser into their text editor? I
> know you can right click, and "save target as" (or what ever your system states
> precisly), besides I would prefer *not to tell* my visitors how they are supposed
> to do it I would rather have happen automatically (thats what computeris for after
> all , right :-)).

You probably can't accurately tell everyone how to save the
file. That's not a knock - I seriously doubt that *anyone* can do
that. Many people close their eyes and pretend that there are only one
or two browsers - but they are off by at least two orders of
magnitude. Such people also tend to pretend that browsers don't have
configuration options, meaning their sites fail in obnoxious ways for
users who have found and used the Preferences menu.

> But as stated, the .txt file is not there for your eyes to glaze upon, it is there
> for you to quikly edit, or to run it so that you can get a feeling of how
> everything works.

Well, *most* browsers are configured to display text files as
such. However, how a file is treated by the browser is controlled by
the *user*. I know that companies peddling browsers, servers, HTML
authoring software and the like try to pretend the HTML author
controls things, but that just ain't so. How a file fetched by the
browser is treated is controlled by the MIME type in browsers that
follow the standards, and by the file extension in MSIE.

> So is it possible? To make text editor open and show the file?

Yes, it is. You have to pick an extension (say ".edit") and a MIME
type (say "text/x-editable"), then configure your server to send all
files with your chosen extension as your chosen mime type. Finally,
you have to tell the users how to configure their browser so that it
opens an editor on the the fetched file when they get a file of the
chosen mime type, or of the chosen extension if they are using MSIE.

Alternatively, you could just send it as text/plain, and let them use
whatever way is most comfortable for them to get the file into a text
editor.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list