Forum Moderators: mack
oh - and welcome to WebmasterWorld :)
<script type="text/javascript" language="Javascript" src="filename.js">
</script>
This goes into the BODY into the appropriate placement and does not need to be echoed in the HEAD section. Then the file named filename.js contains the content.
To create it is pretty easy. Insert your content into the main document and format it until it looks the way you want it. Then remove that code, complete with formatting codes and put it into the filename.js file and add in the necessary javascript changes into the .JS file and the <script> command into the .HTML file. I generally rely on the
document.write (" ");
command line for my external .JS file. Don't forget to comment out the quotes that are a part of the navigation, with a backslash (\), like
document.write ("<a href=\"filename.htm\"></a>");
And to make sure the spiders and Linux users are not completely confounded by the javascript menus, I try to have at least the index page containing the menus unadulterated by javascript.
I found a really great free javascript to replace the menus on my website
I'd just like to emphasise what gcross pointed out - if you use javascript for all your menus then people with javascript turned off will not be able to navigate your site, and neither will spiders.
Make sure you supply an alternative means of navigation - or consider using CSS instead of Javascript to make pretty looking menus (depends what you want it to do really, but CSS can handle all the usual prety hover effects).
"...Don't forget to comment out the quotes that are a part of the navigation, with a backslash (\), like
document.write ("<a href=\"filename.htm\"></a>"); ..."
It is a good idea to get in the habit of using one set of quotes for html and the other for javascript. For example:
document.write ('<a href="filename.htm"></a>');
You still might need to escape quotes from time to time, depending on the context, but much less often, and the code will be easier to read and debug.
Shawn
You also need to escape the / of the closing </a> tag, and of any other closing tags, by changing to this format: <\/a> instead.