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!

Is there something like C-language "#include" for HTML? 1

Status
Not open for further replies.

tystent

Programmer
Jan 25, 1999
15
US
I have a block of HTML that has to occur in many different pages, but the block will change every now and then, and I hate having to change it on every page each time. I've heard of <IFRAME> but it doesn't seem to work with my Netscape 4.5.
 
Use a 'server-side include statement &lt;!--include file=".."--&gt; <br>
or &lt;!--include virtual=".."--&gt;.<br>
SSI pages often hava an '.shtml' or '.stm' file extension, depending<br>
on your web server and its configuration.<br>

 
If your server can't handle SSI's:<br>
<br>
How about serving up the included material in a separate JavaScript file (a .js file) using the document.write() command? Just call the .js file using &lt;script language="JavaScript" src="script-file.js"&gt;&lt;/script&gt; in the approriate spot in your document.<br>
<br>
Problem with this is, it won't work in IE 3.
 
Thanks for the help. The SSI works great, and it's just what the doctor ordered. Of course it all depends on the server's capabilities. In my case, my server is GeoCities and they allow SSI on standard .htm or .html files, since they use it themselves for their add-ons to your page. (I.E., they're already parsing your files to add their stuff, so it's not much more of a load to parse for your #include's, so no additional speed problem.)<br>
<br>
The javascript will be my next project, but then you have to ask some viewers to update their browser...
 
Rudolf,

Would the include statements also work with .asp file extensions?? Please let me know!

Thanks.

-Henry
 
You want to include a cgi script, external js file, or asp stuff?

-I dont think you can get SSI to work in asp - but maybe
-External js files will work fine
-I'm not much for asp, but there is a way to include other files -- i dont remember how, sorry :) -gerrygerry
geraldschafer@hotmail.com
 
Hello all!

Certainly you may use SSI with ASP:
<!--#include file=&quot;path&quot;-->
or
<!--#include virtual=&quot;path&quot;-->

Good Luck!
 
Server Side Includes... a script or program that is executed on the server and 'writes' to the page it is called from... Like this:

I have a perl script called header.pl that looks like this:
Code:
       print &quot;Content-type: text/html\n\n&quot;; 
       print &quot;This is my header&quot;; 
       exit;
-->UNTESTED<--

Then in my HTML page ( usually has a .shtml extension because it uses SSI):
Code:
 <html>
  <head>
   <title>My Page</title>
  </head>
  <body>
Code:
    <!--#include file=&quot;/cgi-bin/header.pl&quot;-->
Code:
  <br>
   This is more text.
  </body>
 </html>

You can also use SSI to include other documents (.htm, .txt, etc).

Any other questions? -gerrygerry
Go To
 
I thought there was a different SSI tag to get it to execute a program that outputs text (like <!--#exec ...>?). I think that include just inserts the file, not executes it. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
A star and a &quot;gotcha&quot; on consecutive threads? Looks like you're doing about as well as I usually do. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
teenmonk, ASP has it's own include statement or are you referring to including an .asp page to an .html page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top