iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
May 14, 2008
Build Beautiful Buttons in Photoshop, Part I
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /JavaScript

Using JavaScript As An Alternative to SSI 

  Views:    10727
  Votes:    2
by Mark Klink 12/15/03 Rating: 

Synopsis:

If you're tired of updating every page of your site, everytime you make a change to your navigation, or any other portion of your site, then you're not alone. You could use Server Side Includes, unless your host doesn't allow it. Then what? Welcome to the wonderful world of JavaScript.
Pages: firstback1 forwardlast
The Article

Browser Compatible Version

As stated the first method only works in Internet Explorer, while this second method will work in any browser that has JavaScript enabled, which is actually the majority.

Method 2:

Much like method 1 we will be creating an external js file to include in your pages directly.  So lets get started.

Step 1:

Unlike in method 1, you will not need to create an external page for your navigation, as it will all be included in your js file, using the code format below:

document.write(" your navigation code will go here ");

Notice the highlighted area. This is where your navigation HTML code will go. The one thing to keep in mind when coding javascript in these methods, is the use of backslashes.

You need to preceed every quotation mark (") within the highlighted area with a backslash (i.e. \" ). You will receive errors otherwise.

Once you have created the code above, save it as navinclude.js

Step 2:

Now you'll just need to include the navigation into your pages with the following code:

<SCRIPT language="Javascript" src="navinclude.js">
</SCRIPT>

Using any of these methods, will cause each page of your site to update when you update the one source file. So basically, in method 1, you would update navigation.html, and this would update your navigation on every page.

In method 2, you would update the navinclude.js file.

You can use either method you prefer, and have a dynamically updatable site, without all of the headaches of updating each individual page. So, have fun! You can use the extra time to catch up on some reading, or learn how to grow oranges or something.

Pages: firstback1 forwardlast

Similar/related articles:


 
  Sponsors