navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Free FrontPage Templates

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Showing a txt file in IE

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> Showing a txt file in IE
Page: [1] 2   next >   >>
 
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
Showing a txt file in IE - 2/22/2002 13:07:00   
I have a hyperlink on a page that links to a txt file. When clicked, the txt file opens up in IE. This is what I want. However, IE does not word wrap the lines. It shows an entire paragraph as one really long line and I have to scroll left and right to read the page.

Is there a way to open the page, in the same or new window (I don't care), but with word wrap?

Thanks,
Andrew

----------------------------------------------

ALERT
! Totally Useful Code !

This thread has been summarized, with implementation instructions, at the bottom.


----------------------------------------------

webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

Edited by - SerenityNet on 02/27/2002 13:29:09
abbeyvet

 

Posts: 5095
From: Kilkenny Ireland
Status: offline

 
RE: Showing a txt file in IE - 2/22/2002 13:17:41   
This sounds like a perfect scenario for using the <pre> tag (my latest fav!) that I wrote about in last weeks newsletter.

Here's how it goes.

Create a new page in FP, go to html view and just after the <body> tag put

<pre>
HERE
</pre>

Now highlight the word HERE (still in HTML view) then copy and paste your text from the notpad file in its place.

It will look a mess in html view but when you switch back to normal or preview you will find that the notepad formatting has been perfectly preserved.





Katherine

++++++++++++++++++++++++
www.inkkdesign.com

"Dogs have owners, cats have staff"
Meeeooow!

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/22/2002 14:15:04   
Thanks Katherine. I'll keep this in mind for future use, but it doesn't work for me this time. I should have given you more details.

I'm using a txt file to store my code snippets. With Notepad, it opens quickly from a shortcut and I can copy code to it fast. But sometimes I just want to look at the file from my browser (usually IE). I don't want to have to modify an HTML file every time I want to add a snippet. I just want to display the txt file in my browser cleanly.

Is there another way you can think of?

Thanks again,

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
Justjay

 

Posts: 697
From: Montreal, QC Canada
Status: offline

 
RE: Showing a txt file in IE - 2/22/2002 18:26:22   

Was word wrap turned on in Notepad?


Justjay
http://www.thejehm.net
http://www.thejehm.net/tne

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/22/2002 18:42:51   
Yes.

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
DarlingBri

 

Posts: 3123
From: Left of Centre, Cork, Ireland
Status: offline

 
RE: Showing a txt file in IE - 2/23/2002 2:32:33   
Then make the page that Katherin told you about and store it on your hard drive. Bookmark it in your browser, and instead of opening the non-wrapping text file, open the <pre>wrapping htm file.

--Bri
-----
#!usr/bin/girl

(in reply to SerenityNet)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Showing a txt file in IE - 2/24/2002 15:08:09   
How are you saving the original text file?
It sounds as if the carriage return is not recognized - it shouldnt make a difference how it is opened

§þððk¥
Database / DRW Q & A
VP-ASP Shopping cart
Spooky Login

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/24/2002 20:38:31   
Using Notepad (with word wrap turned on), I've saved as ANSI, Unicode, Unicode, Unicode big endian, and UTF-8. When I view the file in IE using the path: http://localhost/_includes/snippets.txt then paragraphs are just one long line in the window. I have to scroll left and right (horizontally) to view the whole paragraph.

I was just hoping for a way to get the txt file to word wrap in an IE window the same as it does in Notepad.

I've tried the <pre> tag, but then I have to maintain two files (the text file and the html file). I tried using the txt file as an includes page, but I guess only asp and html files can be used that way.

The only solution I've found is to just create my txt file with manual line breaks (every 80 characters or so).

Thanks

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/25/2002 2:45:32   
Hi Andrew,

May I suggest you copy your code snippets from Notepad and paste them into WordPad. Then in WordPad save as Text - MS-Dos Format.

When you open it subsequently to add code with Notepad, it will wrap.

Go to http://www.biblewitness.com/dbtest/wrap.htm and click on ms.txt



William Lee

Edited by - William Lee on 02/25/2002 02:53:56

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/25/2002 19:41:42   
Thanks William, but that's not it either (at least for the way my browser shows it).

Please see http://www.serenitynet.net/snippetsTEST.txt

This text file works great in both WordPad and Notepad, where I will maintain the file. But I'd like to be able to view it in my browser. Unless I use manual line breaks (hit the enter-key), I've not yet seen a way that IE will display the txt file without having to use the horizontal scroll bar.

Beginning to think it's impossible,

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/25/2002 23:06:39   
ok now I understood what you meant in your other post about ASP opening a window without hscrollbar.

The ASP way then:
http://www.biblewitness.com/dbtest/display.asp?TxtFileName=snippetsTEST.txt

The code
<%
sFile=Request("TxtFileName")
Set FSO = CreateObject("Scripting.FileSystemObject")

Set objM = FSO.OpenTextFile(Server.MapPath(sFile))

MsTxt = objM.ReadAll
objM.Close

MsTxt=Replace(MsTxt,vbCrLf,"<BR>")
MsTxt= "<Center><Table Width='300'>" & MsTxt
MsTxt= MsTxt & "</Table></Center>"

Response.Write MsTxt
%>

The above code works from wrap.htm which passes the Text filename to display.asp.
You can put sFile="snippetsTEST.txt" instead of Request("TxtFileName") in your one asp page and call "snippetsTEST.txt" in the asp page everytime in your browser.



Edited by - William Lee on 02/26/2002 05:42:23

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/26/2002 1:07:06   
<sic> *ignore this, I was trying to edit the above post

Edited by - William Lee on 02/26/2002 01:10:41

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/26/2002 19:01:39   
Yeah! Now we're getting somewhere!

The problem remaining is that the txt file contains ASP, HTML, and JavaScript code.

I've tried putting the <pre> tags at the start and end of the text file (and also within the red code), but then the text is just truncated at 300 characters. And most of the code is executed anyway.

Please take a look at http://www.serenitynet.net/Experimental/testing_txt_display.htm for an example of what's happening.

Thanks again,

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/26/2002 22:12:32   
Hi Andrew,
Add this

MsTxt=Server.HTMLEncode(MsTxt) before the line MsTxt=Replace(MsTxt,vbCrLf,"<BR>")

See http://www.biblewitness.com/dbtest/display.asp?TxtFileName=javascript.txt



William Lee

Edited by - William Lee on 02/26/2002 22:26:25

Edited by - William Lee on 02/26/2002 22:31:12

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/26/2002 22:57:31   
!!!This Is It!!!
Thank you. I would never have achieved this on my own.

It looks like a lot of others have been reading this thread, so I'd like to publish a summary of the final solution. But I have one final question. If the txt file is in another directory from the one where the display.asp resides, then how do you define the path in the code? (I've given it a couple of tries, but only get errors.)

If you can give me that, I think that about wraps up any questions anyone could have and I'll put a nice setup and implementation summary below.

Thanks again,
Andrew

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/26/2002 23:34:23   
I would just do it like this
http://www.biblewitness.com/dbtest/display.asp?TxtFileName=directory2/ms.txt

Is it only 1 text file we are talking about?
Then change sFile="directory2/snippets.txt" in your snippets.asp.

Your snippets.txt seems to be a treasure chest for webmasters. Any chance I can get a copy of it?



Edited by - William Lee on 02/27/2002 04:04:00

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 8:39:25   
This is so cool! Thank you again.

And yes, of course, you can certainly have a copy of the snippets. Right now I'm trying to compose a neat little summary of all the code and how to implement it (with options). I'll publish it below, along with a hyperlink to the snippets.

Thanks again,

Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 13:26:12   
Perfectly Simple
! ! ! Totally Useful Code ! ! !

"Thank you" William, Katherine, Spooky, and everyone that contributes to the OutFront forums. This has to be the best web help community ever!

I can see how the code William has written here could be very useful to someone that wants to populate web pages, or page elements, with txt file information sent or uploaded by a client. For this reason, I'm summarizing this thread's discussion in the text below.

--------------------------------


Goal: Have a web page, or element within a web page, display a separate txt file document while constraining the width of the display as desired (so the viewer doesn't have to scroll the viewing window left and right).

1. You will need a web page (let's call it "Page1") where you place hyperlinks to a separage page (let's call it "display.asp") that will display the txt file (called "FileOne.txt").

The hyperlink on Page1 is:
<a href="display.asp?TxtFileName=FileOne.txt">DisplayFileOne</a>


For another file, use another hyperlink, like:
<a href="display.asp?TxtFileName=FileTwo.txt">DisplayFileTwo</a>



2. Create a new page and call it "display.asp".

The following code is placed between the <body> tags in the "display.asp" page where you want the txt file to appear. (This one code will work for all hyperlinks directed to it.)
<% 
sFile=Request("TxtFileName")
Set FSO = CreateObject("Scripting.FileSystemObject")

Set objM = FSO.OpenTextFile(Server.MapPath(sFile))

MsTxt = objM.ReadAll
objM.Close

MsTxt=Server.HTMLEncode(MsTxt)
MsTxt=Replace(MsTxt,vbCrLf,"<BR>")
MsTxt= "<Left><Table Width='600'>" & MsTxt
MsTxt= MsTxt & "</Table></Left>"

Response.Write MsTxt
%>


3. Of course, there are variations you can use.

Other Notes:
  • If your txt file is in a different directory than the display.asp page then your hyperlink on Page1 needs to identify the path to the txt file, like:
    <a href="display.asp?TxtFileName=Directory2/FileOne.txt">DisplayOne</a>

  • The line "MsTxt=Server.HTMLEncode(MsTxt)" can be deleted if you would like html tags within the txt file to work. If left off then javasript and asp code within the txt file will also be implemented.

  • You can change the width value to whatever you want.

  • This even displays correctly in Netscape 4.75+ Wow!

  • Don't forget to look at Katherine's use of the <pre> tag in the thread above. If you choose to have the txt file containing HTML code then you may find the <pre> tag very useful.



4. Code Snippets
  • If you want a copy of the snippets I've collected (why this thread started) then right-mouse-click on the hyperlink below & "Save target as..."
    http://www.serenitynet.net/downloads/snippets.txt

  • If you want, send me snippets you've found really useful. As I have time, I'll add them to the file at the url above. Just e-mail them to me in a txt file ready to copy and paste into the existing file. Try to give credit to your source.


Andrew
webmaster@serenitynet.net - But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control..." Gal. 5:22

(in reply to SerenityNet)
Gil

 

Posts: 7533
From: North Carolina, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 15:05:19   
Hmm, on a Unix/Apache box it's a little less coding

Inside a table set to the width you need:
<!--#include virtual="/somedir/file.txt" -->


Gil Harvey
The Host Factory
Resellers are our Specialty
Find a Web Professional


(in reply to SerenityNet)
SerenityNet

 

Posts: 1372
Joined: 6/12/2001
From: Allen, TX, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 15:25:36   
...and you don't get a VB error because the txt file contains ASP &/or JavaScript code?

(in reply to SerenityNet)
EWD

 

Posts: 1052
From: BeauFlow, NY
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 19:57:18   
Glad you brought that up, Gil. I have a calendar program that writes events to a text file that appears to be tab delimited. I would like to be able to display it on an html page in a list, in addition to the regular calendar. So after reading Katherine's PRE /PRE suggestion, I tried this:
<PRE>
<!--#include virtual="/cgi-bin/calendar/file.txt" -->
</PRE>
and all I got was a couldn't process the directive error. The page I was calling it from is in the root.
Any suggestions for me?

 

Edited by - EWD on 02/27/2002 19:59:32

(in reply to SerenityNet)
caywind

 

Posts: 1479
From: USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 22:19:14   
Hey Iv'e been thinking about that. A Snippet vault! I know we all have snippets somewhere. Actually that's what i find myself saying, "now where did I put that snippet?"

<spellcheck> </spellcheck>

Also, does this work in Linux?

Edited by - caywind on 02/27/2002 22:28:39

(in reply to SerenityNet)
Gil

 

Posts: 7533
From: North Carolina, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 22:23:16   
quote:

Glad you brought that up, Gil. I have a calendar program that writes events to a text file that appears to be tab delimited. I would like to be able to display it on an html page in a list, in addition to the regular calendar. So after reading Katherine's PRE /PRE suggestion, I tried this:
<PRE>
<!--#include virtual="/cgi-bin/calendar/file.txt" -->
</PRE>
and all I got was a couldn't process the directive error. The page I was calling it from is in the root.
Any suggestions for me?


If the CGI script is writing the test file on the fly you probably need <!--#virtual = "/cgi-bin/calendar.cgi" -->

Gil Harvey
The Host Factory
Resellers are our Specialty
Find a Web Professional



Edited by - Gil on 02/27/2002 22:26:08

(in reply to SerenityNet)
Gil

 

Posts: 7533
From: North Carolina, USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 22:34:15   
quote:

...and you don't get a VB error because the txt file contains ASP &/or JavaScript code?



Nevet tried to show HTML code as ascii, I would guess you'r UUENCODE it some how - nowyou got me thinking

Gil Harvey
The Host Factory
Resellers are our Specialty
Find a Web Professional


(in reply to SerenityNet)
caywind

 

Posts: 1479
From: USA
Status: offline

 
RE: Showing a txt file in IE - 2/27/2002 23:36:16   
Sorry, just noticed Gils one liner
quote:
Hmm, on a Unix/Apache box it's a little less coding

Inside a table set to the width you need:
<!--#include virtual="/somedir/file.txt" -->



Confirming the bug even in Linux. The form text wordwraps as you type it,
in the form, but in an include page or asp it will move off of the right of the screen.
Line break problem.

To backtrak a little this thread was dealing with
letting users update pages and then having those pages post in other pages.

A solution was offered for NT and ASP...
quote:
1. You will need a web page (let's call it "Page1")
where you place hyperlinks to a separage page (let's call it "display.asp")
that will display the txt file (called "FileOne.txt").

The hyperlink on Page1 is:


<a href="display.asp?TxtFileName=FileOne.txt">DisplayFileOne</a>

For another file, use another hyperlink, like:


<a href="display.asp?TxtFileName=FileTwo.txt">DisplayFileTwo</a>


2. Create a new page and call it "display.asp".

The following code is placed between the <body> tags in the "display.asp"
page where you want the txt file to appear. (This one code will work for
all hyperlinks directed to it.)

<somebody please comment this code>
<%sFile=Request("TxtFileName")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objM = FSO.OpenTextFile(Server.MapPath(sFile))
MsTxt = objM.ReadAllobjM.CloseMsTxt=Server.HTMLEncode(MsTxt)
MsTxt=Replace(MsTxt,vbCrLf,"<BR>")MsTxt= "<Left>
<Table Width='600'>" & MsTxtMsTxt= MsTxt & "</Table></Left>
"Response.Write MsTxt%>


I have solved this in Linux using GILS suggestion (include files)
1. Password protected page contains the input form for an article,
2. On submit, the form saves it's results as an "Formatted text within HTML" file,
in a folder called, say USER_Submissions. so it's ../USER_Submissions/joesfile.htm.
This format gives the results using the <pre> tags.
3. I have another page that contains a logo,nav, and then an include component
The contents of the include is the file that is outputted from the form
../USER_Submissions/joesfile.htm.
4. For editing and blanking of the submissions, the user uses FP, which can edit or
delete the results pages.

I tried to use a size attribute in the <pre> tag but it is ignored?
I think I tried that before and it didn't work then either...
<coder>Ginnie, you around?, my external CSS sheet said
pre {
yada;
yada;
width: "90%";
}
</coder> is that ok? I'm to lazy to look for the descs for <pre>.

I will be testing the suggestion about using a cell in a table...
Has anybody ever tried one of the other formats, <dl> or <ul>

I Set-up my form to output "HTML definition list" -
I now get the tags <H3> and <p>, instead of <pre>.
The text in the field now will wrap within the window and
I can also use the width: descriptor in the external/css
file for <p> and that works

So the news is that using it in a table did work!
Also using the definition list output gave me
two tags <H3> and <p> for the css sheet that controls output.
The width attribute does work on these tags however a very long word
will still make the horizontal scroll bar
appear just as it should...

Edited by - caywind on 02/28/2002 04:01:37

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/28/2002 3:55:45   
quote:

Hey Iv'e been thinking about that. A Snippet vault! I know we all have snippets somewhere. Actually that's what i find myself saying, "now where did I put that snippet?"

<spellcheck> </spellcheck>

Also, does this work in Linux?

Edited by - caywind on 02/27/2002 22:28:39



Not on Linux server unless it is installed with Third party ASP software like ChilliSoft!ASP.


William Lee

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/28/2002 3:57:57   
quote:

Sorry, just noticed Gils one liner
quote:
Hmm, on a Unix/Apache box it's a little less coding

Inside a table set to the width you need:
<!--#include virtual="/somedir/file.txt" -->



Confirming the bug even in Linux. The form text wraps as you type it, but in an include page it will move off of the screen. Line break problem, my form results are currently being saved as "Formatted text within HTML". That gives the <pre> tags. I tried to use a size attribute in the <pre> tag but it is ignored. I will be testing the suggestion about using a cell in a table...Has anybody ever tried one of the other formats, <dl> or <ul> ?


<spellcheck> </spellcheck>



I too just noticed the one-liner. sorry


William Lee

(in reply to SerenityNet)
caywind

 

Posts: 1479
From: USA
Status: offline

 
RE: Showing a txt file in IE - 2/28/2002 4:08:57   
Hey William...looks like my <longwinded> answer to my own question got in six minutes before your </longwinded> <terse> one </terse>

<spellcheck> </spellcheck>

(in reply to SerenityNet)
caywind

 

Posts: 1479
From: USA
Status: offline

 
RE: Showing a txt file in IE - 2/28/2002 4:13:26   
You know what I did I edited a post instead of replying...It's back on the first page, next to last post....

<spellcheck> </spellcheck>

(in reply to SerenityNet)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Showing a txt file in IE - 2/28/2002 4:14:24   
quote:

Hey William...looks like my <longwinded> answer to my own question got in six minutes before your </longwinded> <terse> one </terse>

<spellcheck> </spellcheck>



You sure did!


I also noticed your edits are not quoting SerenityNet as the way he puts it. Was it some typo error?


William Lee

(in reply to SerenityNet)
Page:   [1] 2   next >   >>

All Forums >> Web Development >> General Web Development >> Showing a txt file in IE
Page: [1] 2   next >   >>
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts