|
|
|
date: Fri, 21 Sep 2007 21:33:03 -0400,
group: microsoft.public.inetsdk.programming.scripting.jscript
back
Re: Getting text from a file using JavaScript or an HTML attribute
I already know the filename, what I am looking for is a way to assign text
from that file to an HTML element. For example, if I had the capability to
redesign, say, the <pre> tag, it would look something like the following:
<pre src="/mytextfile.txt"></pre>
I don't really care what tag it is, but I need to tell the tag what text to
display by specifying the filename/path, but as far as I know none of the
tags offer this option. I would be willing to do this with JavaScript as an
alternative, but as far as I know JavaScript does not have a way to read
files (if there is a way, please let me know). Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in message
news:uYrhHxM$HHA.4956@TK2MSFTNGP06.phx.gbl...
> It is not clear whether you are asking how to read a file or how to
> derermine the filename to use.
>
> If you are requesting assistance with determination of the filename to use
> then it is not clear what the criteria is for that determination. If you
> are familiar with the DOM or with DHTML then it is likely easy to design
> something good.
>
>
> "Nathan Sokalski" wrote in message
> news:%239bM$hL$HHA.5840@TK2MSFTNGP03.phx.gbl...
>>I have a situation in which I would like to retrieve text from a text file
>>(such as a *.txt file) dynamically in my page, and I want to be able to
>>change which file this is using JavaScript. If there was an html tag that
>>had an attribute to specify the path to the text file (sort of like the
>>src attribute of the img tag), that would be great, but I don't believe
>>such a thing exists. Saving all the text from all the files in JavaScript
>>variable when initially generating the page (I am using ASP.NET, a
>>server-side technology) would increase the size of the load time by such a
>>huge amount it would be horrible. I am working on using AJAX, but it would
>>be much simpler and nicer if I could just set an attribute. (I know this
>>is not an HTML newsgroup, but I don't think the microsoft.public
>>newsgroups contains one for HTML, except for one that only has 2 postings,
>>which basically means nobody uses it anymore). Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>
date: Sun, 23 Sep 2007 00:57:03 -0400
author: Nathan Sokalski
Re: Getting text from a file using JavaScript or an HTML attribute
That is quite different from what I understood in the original question. So
this clarification is important.
Try the following.
<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-16">
</head>
<Script Language=JavaScript>
function Update() {
var fs, a, ForAppending;
ForReading = 1;
fs = new ActiveXObject("Scripting.FileSystemObject");
a = fs.OpenTextFile("c:\\testfile.txt", ForReading, false);
SeeTextAreaName.value = a.ReadAll()
a.Close();
}
</Script>
<body>
<p><Input Type="Button" Value="Update" OnClick="Update()"></p>
<p><TextArea Name="SeeTextAreaName" Rows=6 Cols=60>
Initial value of a TextArea.</TextArea></p>
</body>
</html>
"Nathan Sokalski" wrote in message
news:enKJp4Z$HHA.464@TK2MSFTNGP02.phx.gbl...
>I already know the filename, what I am looking for is a way to assign text
>from that file to an HTML element. For example, if I had the capability to
>redesign, say, the <pre> tag, it would look something like the following:
>
> <pre src="/mytextfile.txt"></pre>
>
> I don't really care what tag it is, but I need to tell the tag what text
> to display by specifying the filename/path, but as far as I know none of
> the tags offer this option. I would be willing to do this with JavaScript
> as an alternative, but as far as I know JavaScript does not have a way to
> read files (if there is a way, please let me know). Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in message
> news:uYrhHxM$HHA.4956@TK2MSFTNGP06.phx.gbl...
>> It is not clear whether you are asking how to read a file or how to
>> derermine the filename to use.
>>
>> If you are requesting assistance with determination of the filename to
>> use then it is not clear what the criteria is for that determination. If
>> you are familiar with the DOM or with DHTML then it is likely easy to
>> design something good.
>>
>>
>> "Nathan Sokalski" wrote in message
>> news:%239bM$hL$HHA.5840@TK2MSFTNGP03.phx.gbl...
>>>I have a situation in which I would like to retrieve text from a text
>>>file (such as a *.txt file) dynamically in my page, and I want to be able
>>>to change which file this is using JavaScript. If there was an html tag
>>>that had an attribute to specify the path to the text file (sort of like
>>>the src attribute of the img tag), that would be great, but I don't
>>>believe such a thing exists. Saving all the text from all the files in
>>>JavaScript variable when initially generating the page (I am using
>>>ASP.NET, a server-side technology) would increase the size of the load
>>>time by such a huge amount it would be horrible. I am working on using
>>>AJAX, but it would be much simpler and nicer if I could just set an
>>>attribute. (I know this is not an HTML newsgroup, but I don't think the
>>>microsoft.public newsgroups contains one for HTML, except for one that
>>>only has 2 postings, which basically means nobody uses it anymore).
>>>Thanks.
>>> --
>>> Nathan Sokalski
>>> njsokalski@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>
>>
>
>
date: Sun, 23 Sep 2007 00:10:30 -0700
author: Sam Hobbs _change_social_to_socal
Re: Getting text from a file using JavaScript or an HTML attribute
heres a client side include article (using jQuery), also with a few
links to two
other cool client side include implementations...
http://johannburkard.de/blog/programming/javascript/inc-a-super-tiny-client-side-include-javascript-jquery-plugin.html
D.
Nathan Sokalski wrote:
> I have a situation in which I would like to retrieve text from a text file
> (such as a *.txt file) dynamically in my page, and I want to be able to
> change which file this is using JavaScript. If there was an html tag that
> had an attribute to specify the path to the text file (sort of like the src
> attribute of the img tag), that would be great, but I don't believe such a
> thing exists. Saving all the text from all the files in JavaScript variable
> when initially generating the page (I am using ASP.NET, a server-side
> technology) would increase the size of the load time by such a huge amount
> it would be horrible. I am working on using AJAX, but it would be much
> simpler and nicer if I could just set an attribute. (I know this is not an
> HTML newsgroup, but I don't think the microsoft.public newsgroups contains
> one for HTML, except for one that only has 2 postings, which basically means
> nobody uses it anymore). Thanks.
>
date: Tue, 16 Oct 2007 20:57:02 -0700
author: dNagel
|
|