Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Read text file from JavaScript


Message #1 by bmcelhany@h... on Sun, 17 Feb 2002 22:12:51
Thanks. Question though...is this script Netscape specific, and if so is 
there anything comparable for IE? The reason I ask is because much of the 
code I'm using only works in IE.

Thanks.

>
<script language="JavaScript"><!--
> function readFromFile(filename) {
>   var text = '';
>   var filechar;
>  
> netscape.security.PrivilegeManager.enablePrivilege
('UniversalFileAccess');
>   var file = new java.io.File(filename);
>   var FileReader = new java.io.FileReader(file);
>   filechar = FileReader.read();
>   while (filechar != -1) {
>     text = text + String.fromCharCode(filechar);
>     filechar = FileReader.read();
>   }
>   FileReader.close();
>   return text;
> }
> 
> alert(readFromFile('test.txt'));
> //--></script>
> 
> 
> --- bmcelhany@h... wrote:
> > Hi,
> > I'm trying to set the source of an iframe document
> > to the data that's in a 
> > a text file. Is there any way, using client-side
> > JavaScript, to allow the 
> > user to navigate to a text file on their hard drive,
> > and then 
> > document.write the file's data to an html page?
> > 
> > Thanks in advance!
> $subst('Email.Unsub').
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com

  Return to Index