kannanvenkatesh
06-06-2002, 01:30 PM
I want to read from a text file using JavaScript. I want to know whether it is possible.
For example: I have stored some name in a text file and i want my html web document to display it by directly reading from the text file. Is this thing possible using Javascript. Please help me
Thanks in advance :)
ChiefRedBull
06-06-2002, 02:15 PM
JavaScript doesn't have file hadling capabilities. You have to use CGI - perhaps Perl, ASP, PHP..
rich2kchan
06-12-2002, 10:40 AM
I believe that it is actually possible to read files using DataBinding in IE4+
<object id="dataBindId" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="data.txt">
<param name="UseHeader" value="true">
</object>
For example, when u stored a file named data.txt in the following format:
Number,Text,Date,Name,Url
100,abc,19971104,Me,<a href="http://www.irt.org">irt.org</a>
400,zzz,19961003,You,<a href="http://www.microsoft.com">Microsoft</a>
300,fox,19950902,Them,<a href="http://developer.netscape.com">Netscape</a>
50,bad,19981201,Us,<a href="http://www.amazon.com">Amazon.com</a>
u may be able to load them using the following code:
<html>
<body bgcolor = "#ffffff">
<object id="dataBindId" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="data.txt">
<param name="UseHeader" value="true">
</object>
<center>
<table border=1 datasrc="#dataBindId">
<tbody>
<td><div datafld="Number">Number Here</div></td>
<td><div datafld="Text">Text Name Here</div></td>
<td><div datafld="Date">Date Here</div></td>
<td><div datafld="Name">Name Here</div></td>
<td><div datafld="Url" dataformatas="html">Url Here</div></td>
</tbody>
</table>
</center>
</body>
</html>
src found in irt.org