Click to See Complete Forum and Search --> : load textfile


norberto
12-06-2002, 06:22 PM
Hi all!

I am new here ... !
I started with the new FlashMX-Actionscript this year and went very deep into it.
After a couple of month I found out that Javascript is quite equal. Now I go and play with the functions.

And here comes the question:
(tried search, but couldnīt find anything)
I saw the "new array" ... which is quite equal to AS
Is there a possibility to load a textfile too?

___________
Note:
seems I found a thread close to that question lateron. Sorry!
http://forums.webdeveloper.com/showthread.php?s=&threadid=647
But it answers my idea only partly. There has to be a way!

Da Warriah
12-06-2002, 07:37 PM
they cannot load text files per se, but you can just put your file inside a document.write(''); command, save it as either .txt or .js and put <script type="text/javascript" src="blah.txt"></script> - it still works:D

norberto
12-06-2002, 07:42 PM
Hi Dave,
thanks for your answer. First: I am not a programmer. ;-)
Second: I donīt want to use a serverside script.

Lets go ahead:
This I cannot believe. If I can read an array, then I can read a string. Flash reads a textfile like a string. And with flash I can give the string to a javascript and vice versa.
So there has to be a method to get a textfile into a javascript-variable.
Any ideas to bring me to the point?

norberto
12-06-2002, 07:59 PM
Thanks Dave,
I see what you have in mind.

<a href="javascript:oDownload.startDownload('../downloads/customer_email.txt', onDownloadDone);"
style="behavior:url(#default#download)" id="oDownload">customer_email.txt</a>

... works only with IE.

Hmm ...
So back to my question using a kind of middler program.
Using flash to read the file in and gave it out to Javascript.

Here is what I am looking for:
I use flashsites with dynamic content. jpgīs and txt-files.
But when I have to print, it is complicated having context longer then a page. Well, there is a way to work around, but it is quite easier to mix it within a html-file. I thought javascript could help.



------------
Note:
thanks Da Warriah too ...

norberto
12-06-2002, 08:04 PM
Hey Dave ...
.. lets go ahead with your example. Just for playing around. How you would load it into a variable with Javascript?


------------
Info:
I am still sitting on my desk in Europe ... we have 3h in the morning .. I think I should take some hours rest. ;-) ...

Ryan
12-06-2002, 09:09 PM
StringOfText = "Hey, this is a string of text!";

save that as blah.js

<script src="blah.js" type="text/javascript"></script>

place that in your html document, and it acts as if the StringOfText variable were on the page itself instead of in the javascript file.

norberto
12-07-2002, 04:23 AM
@Dave
... thanks for you advice ... and thanks for the scource ... this is one step more into js

@Ryan
... thanks too for the info. Is it possible to load the string instead of using an *.js file?

norberto
12-07-2002, 07:43 AM
is there a possibility to load and to display in this way?



<HTML>
<HEAD>
<TITLE>Stringtest</TITLE>
<SCRIPT>
function onDownloadDone(m) {
mystring= m;
}
// End -->
</script>

</HEAD>
<BODY OnLoad="javascript:oDownload.startDownload('js_download_txt.txt', onDownloadDone);" style="behavior:url(#default#download)" id="oDownload">

<H3>Stringtest</H3>
<SCRIPT LANGUAGE="JavaScript"><!--
var urls = "And here comes the text: ";
document.write(tag("p"))
document.write(urls+"\n"+mystring)
document.write(tag("/p"))
function tag(s){ return "<"+s+">" }
//--></SCRIPT>
</BODY>
</HTML>

norberto
12-07-2002, 07:44 AM
is there a possibility to load and to display in this way?



<HTML>
<HEAD>
<TITLE>Stringtest</TITLE>
<SCRIPT>
function onDownloadDone(m) {
mystring= m;
}
// End -->
</script>

</HEAD>
<BODY OnLoad="javascript:oDownload.startDownload('js_download_txt.txt', onDownloadDone);" style="behavior:url(#default#download)" id="oDownload">

<H3>Stringtest</H3>
<SCRIPT LANGUAGE="JavaScript"><!--
var urls = "And here comes the text: ";
document.write(tag("p"))
document.write(urls+"\n"+mystring)
document.write(tag("/p"))
function tag(s){ return "<"+s+">" }
//--></SCRIPT>
</BODY>
</HTML>

norberto
12-07-2002, 08:47 AM
thanks dave

... but this data= attribute doesnīt fill the string ...

My target is:
When I click on a button in a flashmovie it should open a popup window in html by transferring the filename from flash to Javascript. And JS reads in various pictures from a folder and a textfile containing two variables.

My target to start with is:
read in a textfile using a string, do a bit formating and place it within a table.
Later I would like to split the text with the two parts into an array and to place the text with js in different tables.
and so on ...

I feel a little bit lost ...

norberto
12-07-2002, 12:36 PM
Thanks Dave!
Iīll give it a try!