Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Fri, 21 Sep 2007 21:33:03 -0400,    group: microsoft.public.inetsdk.programming.scripting.jscript        back       


Getting text from a file using JavaScript or an HTML attribute   
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: Fri, 21 Sep 2007 21:33:03 -0400   author:   Nathan Sokalski

Re: Getting text from a file using JavaScript or an HTML attribute   
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: Fri, 21 Sep 2007 20:54:54 -0700   author:   Sam Hobbs _change_social_to_socal

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   
Nathan Sokalski wrote on 23 sep 2007 in
microsoft.public.scripting.jscript: 

> 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>
> 

<iframe src = '/mytextfile.txt'></iframe>

or use Ajax-like technology.

Even better, do this serverside, 
with an include or filesystemobject

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
date: 23 Sep 2007 07:12:45 GMT   author:   Evertjan.

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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us