I have successfully converted my .tiff file to a text file. This was a major step. My issue now that i am facing is "capturing" pertinent data. I am attempting to do this by running a JavaScript to create an HTML file from the .txt file. I am having trouble figuring out how I am going to pass the argument of a .txt file and embedding it into the HTML page.

Thoughts? Anyone? Bueller? Bueller?

dano

JavaScript cannot read a text file. You need to use server side code, such as ASP.NET or PHP, to process a file and render it to HTML.

However, you can store large text strings as JavaScript variables, and use the JavaScript document.write() method to write HTML strings.

Not sure if this will help but a friend wrote some kind of script (.js, .class) or something of that nature to do just what you are wanting. I'll try to send him here to help you out! It was called awrite.js or jwrite.js. I know he had posted it on some java search site, just not sure which one. Once again i'll try to send him here to help you out! In the mean time try a search engine and put in awrite or jwrite. You might be able to find it on the net!

I thought, Javascript can not work with FSO. It's good to see this article.

Ryan
<URL SNIPPED>

The only way to capture or embed .txt file into (x)HTML document, is to use AJAX. Just let me know if you need some example over this thing.

What about JQuery?? jQuery Documentation: http://docs.jquery.com/Ajax/load#urldatacallback
If not maybe try this code:

/*For safety reasons I would only allow the PHP file to determine the location of the file...if you want the ability to pick your file just post and I will modify my code*/
$file = "test.txt"
//Test if file exists
if(file_exists($file))
{
    //Open the file in read mode
    $fp = fopen($file, "r") or die("Error: Cannot open file");
   //Cycle through file
   while(!feof($fp))
   {
      //Return the file for AJAX to use
      echo fgets($fp);
   }
}
else { die("Error: Cannot find file"); }

Oh wow I didn't realize that this thread was that old. Now that I think about it....was jQuery even around back then?

Hi flash,

JQuery is made for shorthand ellaboration of Javascript lines and simplifies the way you write your programs.
And about that documentation that you've provided still uses AJAX Technology. If you will just take a good look over its frameworks, you'll see that all parts of it, is created by the method's, and properties of the Javascript language.

And also if he wants this with PHP, then im sure this query wouldn't be here in the first place.

<html>

<head><title>DOC</title>

<script language="JavaScript">

<!--//

function loadworddoc(){

var doc = new ActiveXObject("Word.Application"); // creates the word object

doc.Visible=false; // doesn't display Word window

doc.Documents.Open("F:\\Users\\Gaurav Srivastava\\Desktop\\Pendrive Backup\\Test.txt"); // specify path to

document


//copy the content from my word document and throw it into my variable

var txt;

txt = doc.Documents("F:\\Users\\Gaurav Srivastava\\Desktop\\Pendrive Backup\\Test.txt").Content;

document.all.myarea.value = txt;

doc.quit(0); // quit word (very important or you'll quickly chew up memory!)

}

//-->

</script>

</head>

<body>

<p><input type=button onClick="loadworddoc();" value="Load">

<p><textarea name=myarea cols=100 rows=25>nothing here yet</textarea>

</body>

</html>

Edited 6 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

This article has been dead for over six months. Start a new discussion instead.