txt file open

Discussion in 'JavaScript' started by weknowtheworld, Apr 14, 2007.

  1. #1
    Hi,

    Can anyone please tell me how Can I Open a Text File (*.txt) In a Textarea ?

    Thanks :)
     
    weknowtheworld, Apr 14, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    u cant with javascript, you'll need to use a server side language to achieve that...
     
    krakjoe, Apr 17, 2007 IP
  3. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    <script>
    var fso, f1
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f1 = fso.CreateTextFile("C:\\WINDOWS\\Desktop\\file name.txt", true);
    // Write a line.
    f1.WriteBlankLines(1);
    f1.Close();
    function CreatAList(){
    var MyWords = document.Picks.Selections.value
    var fso, f1, ts, s, s1;
    var ForReading = 1;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    // Read the contents of the file.
    ts = fs:confused:penTextFile("C:\\WINDOWS\\Desktop\\file name.txt",
    ForReading);
    s = ts.ReadAll();
    s1 = s+MyWords
    ts.Close();
    f1 = fso.CreateTextFile("C:\\WINDOWS\\Desktop\\file name.txt", true);
    // Write a line.
    f1.WriteLine(s1);
    f1.Close();

    }

    </script>

    In this way read the file and then display with document.getElementByid to textarea. Filename.txt content will be available in s1 string.

    I think I am ble to help you out. Any help needed I am here to answer you. :)
     
    Subikar, Apr 17, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    nearly everyone will stop that activex running on thier computer, and those using firefox won't even get the option.
     
    krakjoe, Apr 17, 2007 IP