reading txt files

Is there a way I can read a txt file into javascript? What I'd be looking for is something like this:

=====
textfile.txt
---
a bunch of text is in this file
like maybe a story
or an article
or something like that
=====

javascriptfile.js
---
var textFile = new array();

function show_textFile(txtFile) {
//read the text in txtFile into the textFile array

for (a=0;a<{length of file};a++) {
document.write(textFile[a])
}
}
=====

Comments

  • I'm not sure if this is possible using JavaScript but if you find a way could you e-mail me at goodallalan@hotmail.com . You can use server-side languages to read and write to text files on the server such as ASP and JSP. Another option is to use cookies. For any help on these subjects, e-mail me at the address above.



  • That's too bad, I was afraid javascript wouldn't be able to do that. Thanks though, I'll be sure to send you anything if I do find it.

  • Mabey you can use an tag:







    line = new string()

    line = document.form1.textfile.value;

    I hope this works for you...

    greetz,

    Rogier



  • I realised that what I suggested will not work. I suggest you try using PHP if your provider supports this(most providers do so).

    Take a look at http://www.php.net

    greetzzz
    Rogier




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories