473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to display a text file using Javascript

Is there any sample code to use Javascript to load and display a text
file?

It will be best if the user can select files using some kind of
explorer. If that's complex, a text box to specify the file name will
be fine as well. Once a text file is selected, I just need to display
it in a text box.

Thanks for the help.

Apr 3 '06 #1
3 3871
ji*********@gmail.com wrote:
Is there any sample code to use Javascript to load and display a text
file? I'm not quite sure what your senario is. I assumed that you have make
your files accessible directly on web or through some sort of CGI
program. You have several ways to do the job and the easiest one is to
simply have them rendered in a frame/iframe with their respective urls.

It will be best if the user can select files using some kind of
explorer. If that's complex, a text box to specify the file name will
be fine as well. Once a text file is selected, I just need to display
it in a text box.


There's no such a thing as a 'explorer' in JavaScript which can be used
to browse server-side files. You have to design an 'explorer' page and
have a server program generating the file list.

The way I metioned above is to display your files in a frame/iframe. You
can css-style the frames to make them look exactly like a textbox (but
you will not be able to edit on them of course). If a textbox is really
required in your design, either you generate a page with file content
wrapped in textarea tag on the server-side, or on the client-side you
may consider using HTTPRequest object in JavaScript to fetch those files
and feed the text response to textarea element dynamically.

Hope this would help.
-- Elan Hung
Apr 3 '06 #2

Check around for Asynchronous JavaScript, aka Ajax, will be the way
to do it.

Danny
Apr 3 '06 #3
ji*********@gmail.com wrote:
Is there any sample code to use Javascript to load and display a text
file?
<URL:http://jibbering.com/faq/#FAQ2_3>
<URL:http://jibbering.com/faq/#FAQ2_4>
<URL:http://groups.google.de/groups?as_q=load+OR+save+file&as_ugroup=comp.lang. javascript&scoring=d&filter=0>
It will be best if the user can select files using some kind of
explorer.


<input type="file">
PointedEars
Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
4
by: dmiller23462 | last post by:
I'm trying to create a submission page for users to request PC/LAN Access....If they select "Yes" in the field asking about if they need Non Standard Software, I want several other HTML fields to...
2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
5
by: David Elliott | last post by:
I need a control on a Web Page that can accept an HTML Document and will display it. Any help would be appreciated. Thanks, Dave Here is what I was trying...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.