Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Darren's Scripts Javascript Inlcude Tuturial Javascript Include Tuturial By: Darren

So you want to include pages and not have the hassle of updating every page one by one, but you dont have PHP or SSI? Well guess what? there is a simpler solution, its called the javascript include. Just read the rules below.

1) Create a text file (javascript files or .js extension files tend to take more time to load on the users computer) and type in the following code with what you want to include:

// Begin Javascript Include
document.write('THIS IS WHERE THE INCLUDE HTML GOES')
// End Javascript Include

Note: For every line of coding for your .txt file you must put the tags in it like so: document.write('Line 2 Content')

I know it seems like alot but all you really need to do is cut and paste.

2) Next save it as a text file as whatever you want (IE: file.txt)

3) Go into the page where you want to include the code and insert the following javascript code:

<SCRIPT language=javascript src=yourfile.txt></SCRIPT>

4) Thats it your done!

This script is very useful if you are on a free server such as Geocities or Brinkster and do not have access to PHP or SSI.

Remember you can use as many javascript includes as you want, the only thing different about them is they will not display the html straight from the file, they will show up as the javascript above if you do view source.

© Copyright 2002 Darren's Scripts