Editing Website Template .js Files

Adding New Items to a .js File

You can add new items to .js files. Generally you may want to add a new item to the menu.js, header.js, sidebar.js or copyright.js. You will want to add these items using Notepad in Windows or TextEdit on Mac.

General Rules:
To add any item to a .js file like the sidebar.js put the following in front of every line:


Put this at the end of every line:


Do one line at a time and test to see if the template pages are still working properly before you go to the next line.

NOTE: If you use a ' inside that code anywhere add a slash before it like this \'

Adding some text:
Perhaps you would like to add some text to the menu.js or header.js. You would add that like the following:

document.write(' Just a short note<br> ');

NOTE: This will not work in the menu.js on any drop menu template. Use a " instead of a ' in that case for the above code.

Adding an Image:
Perhaps you would like to add an image with a link to the header.js. You would add that like the following:

document.write(' <a href="newpage.htm"><img src="picts/yourimage.jpg" border="0"></a><br> ');

In the above example notice how this code is breaking into two lines. In the HTML pages make sure this is all on one line. If you need to, turn off "word wrap" under "Format" in Notepad or your text editor.

Adding a Javascript:
You can add a Javascript to any template .js file, however, in this case do not add the following code from your script:

<script type="text/javascript"><!--

And remove this code...

//--> </script>

Adding Google Ads or other items with .js file calls:
Some code or ads you will want to add may include other .js code. In other words you will be adding a .js file inside a .js file. Below is an example of how to add a .js file call inside a .js file.

If your line looks like the following:

<script type="text/javascript" src="http://google.com/coop/cse/brand?form=searchbox_003488088439636726711%3Adzunaemraqw"></script>

One option would be to edit the above line by adding ' + ' in the script text and a \ in front of every / like the following:

document.write('<scr' + 'ipt type="text\/javascript" src="http:\/\/google.com\/coop\/cse\/brand?form=searchbox_003488088439636726711%3Adzunaemraqw"><\/script>');

The above is a complex edit. You will want to take care and be sure to do this edit carefully. Any single error and this may not work. Also see the Adding Google ads to a template support page.

EXAMPLE: Add a Google search box:
Perhaps you would like to add a Google search to the sidebar.js that looks like this:

Google Search

You would want to copy the following code and paste this into your .js file:

In the above example you can also add this item to your .js file and then place this item anywhere on the page you would like. See Using a DIV to Place an Item.

Related Topics:
Editing .js Files in Windows
Using a DIV to Place an Item

Allwebco Template Support

Allwebco Website Template Support

Website Template Support
Website Template Support