Click to See Complete Forum and Search --> : include file
chriscam19
02-28-2003, 04:56 PM
I have to put the same code in over 100 different web pages. I hear that i could just use an include file to make the pages refer to the code instead of me copying and pasting it in all my web pages. can someone explain to me in detail how to do that?
chris
Dan Drillich
02-28-2003, 05:01 PM
Here is an example of including a JS file -
<SCRIPT LANGUAGE="JavaScript1.2" SRC="http://developer.netscape.com/viewsource/smith_menu/menu.js"></SCRIPT>
chriscam19
02-28-2003, 05:03 PM
sorry, just pretend i know nothing. can you explain to me what i need to do to get it the code to every page?
chris
Charles
02-28-2003, 05:10 PM
I would suggest that you do not try to use that method. It will fail for one in ten users.
The best method is to do your including at the server. Talk to your server people to find out what is available. There's ususlly some easy method that actually works.
The next best method is to use the IFRAME element. Not all browsers will support IFRAMEs, so you will have to supply a link to the other file as a back up.
<iframe src="http://www.w3.org/"><a href="http"//www.w3.org/">W3C</a></iframe>
And then there' the method that Dan Drillich has suggested. You use an external JavaScript file to write to each document. But as JavaScript will fail for such a large number of users, you will have to create a third file that contains the included material as a stand alone HTML page and then use the NOSCRIPT element to provide a link to it.
If you are trying to include javascript, put your code in a file called something.js and then call it on each page like this:
<script language="javascript" type="text/javascript" src="something.js"></script>
If you are trying to include HTML, use PHP, SSI, etc...
chriscam19
02-28-2003, 05:15 PM
thanks :)
chriscam19
02-28-2003, 05:33 PM
where do i put the include file, instead the head or body tag?
chris
No, no...not instead of your <head> or <body> tags...In addition to... :p
To include your javascript file, do it like this:
<head>
<script language="javascript" type="text/javascript" src="something.js"></script>
</head>
chriscam19
02-28-2003, 06:26 PM
now when i include the include file in my webpage i get a done but with errors in my browser!
chris