Forum Moderators: open
Thanks!
not sure what you mean by server side.
If your server supports it, for most purposes it is the best solution. However, if your web site is hosted on a server (or your plan does not include it) SSI is not available.
A situation I have recently worked with is a large number of web sites built by local groups, mostly campus organizations. Many are hosted on university systems (university IT departments can be very picky about students and professors using server side anything), free (Geocities, etc.) hosting, and sometimes full featured hosts. A national organization would like the local web sites to display some text from the national organization that changes frequently. We have used IFRAMEs with success. Another method is javascript that references a remote script containing document.write methods.
I notice that both methods are used for affiliate programs and news feeds (that don't use RSS). Both the affiliates and news feeds include links.
As I understand it, server side includes (SSI) require that the server (for most of us, our ISP or educational institution's computer) have the software to insert a file stored on the server into our web page before it is delivered to the viewer's browser.
SSI works independantly of ISPs etc. In this case "server" refers to the computer on which the website is stored.
It's pathetic that client-side (browser) includes are supported for javascript anf for images but not for text/html. However, that is the reality of the situation.
Using javascript to implement essential functionality is to be avoided where possible. In this case, IFrames or SSI is the solution for static html. For dynamic pages (php, etc.) the problem is largely academic.
Kaled.
not sure what you mean by server side. The html would be server side.
When the html page hits the browser, it is now client-side, which is the environment in which Javascript works.
Anything that occurs at the server before the page is delivered is considered a server-side action. This includes dynamic output from scripts or SSI.
So, create a file that contains any redundant data, such as your navigation section. Name it whatever you want (mynav.txt.)
Rename an HTML file with an .shtml extension. This tells the server to parse the page looking for server-side include (SSI) commands.
In that page, replace your navigation with
<!--#include file="mynav.txt" -->
If mynav.txt is in some other directory, you need to use virtual:
<!--#include virtual="directoryname/mynav.txt" -->
The space after the last quote (" -->) is important.
Upload it to the server and request the page (don't forget .shtml, not .html.) If you see nothing at all, server-side includes are not enabled; contact your administrator. If you see "an error occurred while processing this directive" you've done something wrong, Google for SSI docs and tutorials.
SSI works independantly of ISPs etc. In this case "server" refers to the computer on which the website is stored.
It's pathetic that client-side (browser) includes are supported for javascript anf for images but not for text/html. However, that is the reality of the situation.
Very true. In simple html we can source an image from other sites. It seems like we should just easily pull in a file of text (with html tags). When I get appointed ruler of the world that will be on my list of things to change. Of course, that list is already too long :-}
Using javascript to implement essential functionality is to be avoided where possible. In this case, IFrames or SSI is the solution for static html. For dynamic pages (php, etc.) the problem is largely academic.
I always feel doubtful about using javascript for essential functions. However, I have never had any problems clicking on links to JS based news feeds. (not yet,at least).
SSI on a server that can handle it is my preference. I also like php, when available.
I am not familiar with risks that may be involved with IFrames, although I have seen them used and they have worked for me. I don't know about support on older browsers, however.