Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Text to html with javascript?

can I read text into html with javascript?



8:00 am on Aug 24, 2003 (gmt 0)

10+ Year Member

Probably been asked a million times before.

Can a text document be read by javascript and output to a html page?

I mean without pulling a text file into an I frame or something similar is there any client side way to have a text file output into an html page so it can have html formatting ie. retain body font etc so that a client can just make changes to the text file?


10:26 am on Aug 24, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

What you are asking about is really a basic Content Management System (CMS). Javascript alone is not up to the job you describe -- for instance, text files do NOT contain font information, just characters and line breaks.

There is a lot to choose from in CMS -- MacroMedia's Contribute offers something like what you describe for at a modest price, and there are blogging scripts that may also suit your purpose that are freeware.


11:00 am on Aug 24, 2003 (gmt 0)

10+ Year Member

Thanks for that. I realise that text files are the characters only but was hoping maybe that javascript could read text in and output it in some way as to inherit the html body properties etc of the page.


11:15 am on Aug 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Hi Steven

tedster is right, of course. You can't use javascript for what you describe. Javascript doesn't manipulate (read/write) files except for cookies, as it is client side, and allowing file access would compromise security.

Could you describe a bit more of what you are trying to achieve, and perhaps someone can help. For example, you want the file to be on the visitor's machine? So the visitor can change their own file, but no one else would ever see the results? Is the information small enough to fit into a cookie file? Is this on an Intranet, or for a general Internet site?


8:11 pm on Aug 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

JSlib (hosted at MozDev) is a JS wrapper for XPCONNECT controls, and has a nice FIO implementation (also network, sound, zip, &.c). But I doubt that stevenjm is interested in learning to write a Mozilla app, so an extant CMS would be my recommendation as well.



8:36 pm on Aug 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Actually, what about SSI? Can't you use text files for your includes?

Like you have

You make templates that reside in "/" and include text files from "/users/bob" or "/users/mary" &c.


<title>Bob's Page</title>
<!--#include virtual="/users/bob/bob.txt" -->

Wouldn't something like that work (assuming the server supports SSI)? I know next to nothing about server side stuff, but I think that would work...


Purple Martin

5:30 am on Aug 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


The question was about a client side way of doing it. The client side user isn't going to have access to the include files.


8:53 am on Aug 25, 2003 (gmt 0)

10+ Year Member

Thanks everyone for the advice.

What I was hoping to do was to have it so a client could create a text file with a certain name and ftp it to the server where it would be included on a dhtml page.

Server side is out of the question for this particular site because of the type of hosting.

and I did not want the plain text look that using an iframe would provide.


1:24 am on Aug 28, 2003 (gmt 0)

10+ Year Member

Just for future reference can anyone recommend a good free cms preferably without the use of a database?

Purple Martin

1:34 am on Aug 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Sorry, a good CMS will cost money. Luckily not much, Macromedia Contribute is fairly cheap.

Why don't you want one with a database? There's nothing scary about using a database. Sure the hosting is a bit more than those cut-down budget hosting plans, but on the other hand you'll probably get heaps more bandwith thrown in.


4:57 am on Aug 28, 2003 (gmt 0)

10+ Year Member

Thanks. I have macromedia contribute. I have never really looked into cms but did notice there are quite a few free php versions.(eg ezedit etc)that do not require a database.

This is only for future reference for server side options.

Just thought that there may be some more popular of the free ones to save me the time of evaluating quite a few.:)


Featured Threads

Hot Threads This Week

Hot Threads This Month