Javascript Includes

A javascript include is a javascript file that you link to on the pages that you want it to do something. It is similar to a linked style sheet. By using document.write('putyourhtmlhere'); it will write the html in your page for you. One possible use for such a file would be to put a menu at the bottom of all of your pages. By using this method you only have to update the javascript file not every one of your pages. This is definitely a big time saver when you want to update the menu. These are also very helpful for placing advertising on your pages.

document.write('<a href="index.html"><b>Home</b></a> ');
document.write('<a href="search.html"><b>Search</b></a> ');
document.write('<a href="contact.html"><b>Contact Me</b></a>');

The above example should be saved with a name such as "include.js". Then you would link to it using the following.

<script language="javascript" src="include.js"></script>

You don't have to call your file "include.js". I only used "include" because it best describes what I'm trying to show you. You can use whatever you like. This converter will covert your html into javascript document.write files for you. All you have to do is remove the <script>...</script> tag pair and save the code as a .js file. then simply link to it where you want it to appear.

Be sure to remember that whatever you put in a javascript include that it will not be cataloged by search engines. Therefore, it is best not to put any vital information in them.

Highlight The Source Code Below

Highlight The Source Code Below

TIP: Search engines will not catalog anything included in a Javascript include. Therefore, it is best not to use these for placing any vital information on your pages.



<<< Back



Home Page       This Page Was Last Updated: