Webhosting Server Side Includes: Difference between revisions

From AAISP Support Site
(Created page with "link=:Category:Webhosting Our servers do not offer SSI facilities <!--#include virtual="ssi.htm" --> or <!--#include file="ssi.htm" --> however you can cr...")
 
(The workaround only applies to #include)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Our servers do not offer SSI facilities. SSI provides a simple programming language to do a limited set of operations on text. For example, including other HTML files, or printing HTTP environment variables.
[[File:Couk.png|link=:Category:Webhosting]]


E.g.
* <code>&lt;!--#include virtual="ssi.htm" --></code> or <code>&lt;!--#include file="ssi.htm" --></code>
* <code>&lt;!--#echo var="LAST_MODIFIED" --></code>


You can create the same effect for includes by using Javascript (although these will be actually be client side includes). These notes were submitted by a customer and are here to help you.

Our servers do not offer SSI facilities <!--#include virtual="ssi.htm" --> or <!--#include file="ssi.htm" --> however you can create the same effect by using Java Script, these notes were submitted by a customer and are here to help you.


How?
How?


First:
First:


Include the following in the <head></head> section of your page
Include the following in the <code>&lt;head>&lt;head></code> section of your page


<SyntaxHighlight>
<SyntaxHighlight lang="html">
<SCRIPT language="JavaScript" > </SCRIPT>
<SCRIPT language="JavaScript" > </SCRIPT>
</SyntaxHighlight>
</SyntaxHighlight>


and
and
<SyntaxHighlight>
<SyntaxHighlight lang="html">
<script type="text/javascript" src="myincludefilename.js"> </SCRIPT>
<script type="text/javascript" src="myincludefilename.js"> </SCRIPT>
</SyntaxHighlight>
</SyntaxHighlight>


with your own file name substituted where you want the included text to appear.
with your own file name substituted where you want the included text to appear.



Then:
Then:


Create a file myincludefilename.js to hold the text you want to output, then insert the text and wrap each line in a document.write(" "); statement.
Create a file myincludefilename.js to hold the text you want to output, then insert the text and wrap each line in a <code>document.write(" ");</code> statement.


Remember that in JS any newline characters ends the instruction so every line must be wrapped in a document.write statement.
Remember that in JS any newline characters ends the instruction so every line must be wrapped in a <code>document.write</code> statement.


The javascript file can have any extension, and be held in any folder subject to the usual rules about valid pathnames.
The javascript file can have any extension, and be held in any folder subject to the usual rules about valid pathnames.



Example: Good
Example: Good


<SyntaxHighlight>
<SyntaxHighlight lang="js">
document.write("James Brown is in the office <br>");
document.write("James Brown is in the office <br>");


Line 45: Line 42:
Example: Bad
Example: Bad


<SyntaxHighlight>
<SyntaxHighlight lang="js">
document.write("James Brown is in the office <br>
document.write("James Brown is in the office <br>


Line 52: Line 49:


A web search on 'javascript include' will bring up lots more examples.
A web search on 'javascript include' will bring up lots more examples.




==Other Webhosting pages:==
<ncl style=bullet maxdepth=5 headings=bullet headstart=2 showcats=1 showarts=1>Category:Webhosting</ncl>


[[File:aa-button.png|link=http://aa.net.uk/domains-webspace.html|Webhosting Service page on our main website]]
[[File:aa-button.png|link=http://aa.net.uk/domains-webspace.html|Webhosting Service page on our main website]]




[[Category:Webhosting]]
[[Category:Webhosting|Server]]
[[Category:Domains]]

Latest revision as of 16:57, 11 November 2023

Our servers do not offer SSI facilities. SSI provides a simple programming language to do a limited set of operations on text. For example, including other HTML files, or printing HTTP environment variables.

E.g.

  • <!--#include virtual="ssi.htm" --> or <!--#include file="ssi.htm" -->
  • <!--#echo var="LAST_MODIFIED" -->

You can create the same effect for includes by using Javascript (although these will be actually be client side includes). These notes were submitted by a customer and are here to help you.

How?

First:

Include the following in the <head><head> section of your page

<SCRIPT language="JavaScript" > </SCRIPT>

and

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

with your own file name substituted where you want the included text to appear.

Then:

Create a file myincludefilename.js to hold the text you want to output, then insert the text and wrap each line in a document.write(" "); statement.

Remember that in JS any newline characters ends the instruction so every line must be wrapped in a document.write statement.

The javascript file can have any extension, and be held in any folder subject to the usual rules about valid pathnames.

Example: Good

document.write("James Brown is in the office <br>");

document.write("Helen Smith is out of office <br>");

Example: Bad

document.write("James Brown is in the office <br>

"Helen Smith is out of office <br>");

A web search on 'javascript include' will bring up lots more examples.

Webhosting Service page on our main website