The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: parse text file using JS

  1. #1

    parse text file using JS

    Hello little kirupians, here's a little question for you:

    I have a text file, written in such way

    (the .txt is actually 1Mib large)

    Can I parse this text file in an html page using javascript, so each line belongs to an array ? Using split works for characters, but could it work with the linebreak ?



    ps: if anyone knows a way to declare a large chunk of text as a variable (I can't seem to be able to use multi-line variable withouth writing '\' at the end of each line), it would help me greatly !

  2. #2
    Registered User
    I found a sample online ... and edited a bit for our purposes. This reads from a file 'images.txt' on the same directory as the file. Gets the text as a variable and then splits it.

    HTML Code:
    <html xmlns:behave_yaself>
    <script type="text/javascript">
    function downloadEnd(e) {
    	var s=Array();
    <style type="text/css">
    textarea {
    	background-color: #000;
    	color: #FFF;
    	scrollbar-face-color: #FFF;
    <behave_yaself:download id="currFile" style="behavior:url(#default#download);" />
    Click <a href="javascript:document.getElementById('currFile').startDownload('images.txt',downloadEnd)">here</a>
    to start the download. 
    <br />When the download is finished, the text will be displayed in the <b>TEXTAREA</b> below.
    <p><textarea rows="20" cols="40" id="download"></textarea></p>
    PHP Code:
    <zip> echo this; </zip

  3. #3
    thanks, I'll look into it !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012