Reading text files with javascript

Discussion in 'Javascript' started by paulnightingale, Apr 3, 2006.

  1. 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
     
    paulnightingale, Apr 3, 2006
    #1
    1. Advertising

  2. paulnightingale wrote:

    > 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
    <URL:http://www.webdeveloper.com/forum/forumdisplay.php?s=&daysprune=30&forumid=3>.

    >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
     
    Julian Turner, Apr 3, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    3
    Views:
    688
    Kevin Spencer
    Nov 11, 2004
  2. crazyprakash
    Replies:
    4
    Views:
    3,400
    adrian
    Oct 30, 2005
  3. Replies:
    4
    Views:
    974
    M.E.Farmer
    Feb 13, 2005
  4. Replies:
    0
    Views:
    798
  5. Narendra Sisodiya

    Reading files inside zip files from Javascript

    Narendra Sisodiya, Dec 7, 2009, in forum: Javascript
    Replies:
    7
    Views:
    287
    Michael Haufe (\TNO\)
    Dec 8, 2009
Loading...

Share This Page