Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just want to set a variable = a text file

Status
Not open for further replies.

Dutchrg

Technical User
Feb 7, 2001
1
US
Is there any way to write some simple javascript that will just read the contents of a text (.txt) file and then insert the contents? Sort of like:

var x = "
Excecpt that I want to set x to equal the actual contents of the readme.txt file.
 
Hmmm, not sure, but you can read a .js file. You could have a great big string in one of those and read that?

P.S. why do you want to do this? Bj "Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer"
 
um.. unless it a file on the client's machine... and they are running IE... you can't do it with client side script... adam@aauser.com
 
I was wondering about this myself. I have an array of images that the user can cycle through using "next" and "previous" links, and I have a paragraph of text I want displayed with each image. There are 6 images in the array, hence 6 different paragraphs of text. I tried doing this with DHTML using show/hide layers but the results become atrocious with all the browser incompatibilities. Isn't there some way to set up a text/content array so when the user hits "next" and gets "image[2]" he can get the contents of "blurb[2]" displayed WITH the image -- and when he hits "next" again, and gets "image[3]", he will see "blurb[3]" displayed with it instead of blurb[2]?

If anyone can hit me with a clue-by-four here I'd appreciate it. I'm tearing my hair out over this thing. I've been scouring the web for days and can't find *anything* that fits what I'm trying to do. Maybe it isn't doable, but it's so basic and common-sense it HAS to be doable ... right? Help!

Thanks.
R.
 
umm, well, you can use innerHTML in IE and NS6... i recommend ditching NS4.x, but, if you have to use NS4.x you can document.write to layers.

if(document.layers)
{
document.layers["paragraph"].document.open();
document.layers["paragraph"].document.write(blurb[2]);
} adam@aauser.com
 
I was wondering the same thing. I want to redirect from my homepage that i use for my domain name, and forward it to my dynamic ip on my own Apache webserver. I can write the script to update the ip and send it in text form to the static server, but can't think of a way to have the redirect page automatically read that text as the variable it would use to do the redirect. I was also thinking about using the same function on the homepage itself so I could take advantage of the Roger Wilco Base station http-link function. I found how to do it with .php, but for some reason index.php doesn't work on DomainValet, even though it's an Apache server.
 
Kharybdis,

what if your script writes to a text file on the server that you would name ip.js and that would only contain the line:
ip = 'xxx.xxx.xxx.xxx'

next in the head of your redirect page, just include that file with
<script type=&quot;text/javascript&quot; src=&quot;./ip.js&quot;></script>
and then use a second <script> tag to include somthing like
window.location.href=ip;

Bye.

Un fromage havarti en vaut deux.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top