Getting data from a text file : the answer

  • Thread starter Jean-Marie Delapierre
  • Start date
J

Jean-Marie Delapierre

To get data from a text file in an HTML page, using javascript, you sould
wrtie such code ("\" represents a "line continue") :

<head>

<script>

function loadtext () {

var text = document.getElementsByTagName ("object")[0]\
.contentDocument.body.firstChild.firstChild.data;

}

</script>

</head>

<body onload="loadtext ')">

<object data="text_file.txt" height="0" width="0"></object>

</body>

The string variable "text" contains the text of the text_file.txt file.
Then you can split this string to get the individual data.

Regards.

Jean-Marie
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top