Solved

Javascript Write command with contents of a text file

Posted on 2000-03-13
4
160 Views
Last Modified: 2013-11-18
I am writing a set of HTML pages which all have common information at the bottom of a page, which is updated regularly. I don't want to change every page, so I thought that it would be a good idea if all the pages could look up a text file with the common html in it. To do this I thought the write command would be the best option:

document.write(/cgi-bin/TEXTFILE.TXT);

This isn't working. Does anyone have an idea the best way to reach my goal?

Thank you.
0
Comment
Question by:Stoke
4 Comments
 
LVL 4

Accepted Solution

by:
jkunal earned 100 total points
ID: 2611662
change
document.write(/cgi-bin/TEXTFILE.TXT);
to
document.write(./cgi-bin/TEXTFILE.TXT);

;->
0
 
LVL 4

Expert Comment

by:FRehman
ID: 2611708
why you not use the include file
<!--#include file="test.htm"-->
0
 
LVL 19

Expert Comment

by:daveamour
ID: 2611709
You could also use Server Side Includes

eg <!--#include file="../cgi-bin/textfile.txt"-->
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2612125
You can't write a file like that in client side javascript.  Unless you have access to server side javascript, the solution would have to be a javascript include file...
<SCRIPT language="JavaScript" src="/cgi-bin/textfile.js">
</SCRIPT>
notice that it ends in .js

Then the contents of the file has to be javascript code.  You could just have a series of document.write()s in it, like this:

document.write('This is the first line of the footer');
document.write('This is the second line of the footer');

Updating may be a little more difficult since you have to deal with those pesky doucment.writes and watch out for single quotes in your strings...  but this should for you.


-Josh
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now