Reading text files with javascript

  • Thread starter paulnightingale
  • Start date
P

paulnightingale

Hi
I've got a ticker tape that is written in Java Script 1.2 which
displays text that has to be currently changed in the program code.
What I want to do is to find the bit of javascript to get the program
to read a text file so that the text file can be used to update the
contents of the ticker tape. Preferably I will produce a bit of code
that produces a window in which you type the text you want to display
and then this gets saved as a text file, but firstly I need to get my
ticker tape program to read a text file for the content of the ticker
tape. If you have any suggestions on how to do this they would be much
appreciated.

Cheers

Paul
 
J

Julian Turner

paulnightingale said:
Hi
I've got a ticker tape that is written in Java Script 1.2 which
displays text that has to be currently changed in the program code.
What I want to do is to find the bit of javascript to get the program
to read a text file so that the text file can be used to update the
contents of the ticker tape. Preferably I will produce a bit of code
that produces a window in which you type the text you want to display
and then this gets saved as a text file, but firstly I need to get my
ticker tape program to read a text file for the content of the ticker
tape. If you have any suggestions on how to do this they would be much
appreciated.

Cheers

Paul

Hi

This question has probably been answered a few times on this and other
news groups, so it is worth doing some searching on this news group or
From my amateur knowledge, reading a text file may be achived through
the following (depending on security settings):-

1. XMLHttpRequest object

If you set the URL to a local file name, you can access the contents
through the "responseText" property.

This is probably the most cross-browser method.

2. Active X - "Scripting.FileSystemObject"

This is an ActiveX object provided by Microsoft. It is only available
for browsers which support ActiveX, and have the
"Scripting.FileSystemObject" object installed on the client.

As far as I am aware you should find that "Scripting.FileSystemObject"
is commonly already installed on Windows clients.

Example:-

var FSO = new ActiveXObject("Scripting.FileSystemObject");
var nForReading=1;
var oFileObj = FSO.OpenTextFile(sFileName,nForReading, false);
var sFileContents=oFileObj.ReadAll();
oFileObj.Close();

3. XPCOM - Firefox Only

Firefox has XPCOM components. See an example for reading a file at the
bottom of the following page:-

<URL:http://www.captain.at/programming/xul/>

Regards

Julian Turner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top