Web Design Tips

Use JavaScript to Dynamically Update Your Website

by Shelley Lowery

If you've been on the Internet for a while, you've probably seen numerous examples of JavaScript use. JavaScript is a powerful scripting language used to create special effects on your website, but did you know it can also be used as a very powerful web design tool?

Have you ever joined a new affiliate program or created a new publication that you wanted to add to your existing navigational set up, but dreaded having to manually add the links to every page on your site?

You can use JavaScript to enable you to dynamically update every page on your website with just one file. This technique is the same technology used by numerous syndication services on the Internet. It enables them to deliver dynamically updated content to every website in their program.

Before we begin, if you'd like to see an example of a navigational system that is dynamically displayed, visit www.web-source.net. This website has over one thousand pages and each and every one of them displays its navigational system using JavaScript. If I want to add an additional link, I simply update one file and every page on the site is automatically updated.

The first step in setting up your JavaScript feed is to create the file that will contain your content. To do this, open a text editor such as NotePad and simply copy and paste your existing navigational setup into a new page. There is no need to begin the page with <HTML><HEAD>, etc. as you are only creating the feed for one section of your existing web page which already has those tags.

Once you've created your new page containing your navigational HTML, you'll now need to add some additional JavaScript coding to each line of your HTML.

The first line of your new file will look like this: <!--

The next line will begin with: document.writeIn(' and end with: ');

Your first line of HTML will be placed between the beginning and ending coding. For every line of your original coding, you'll need to add the above-mentioned codes before and after.

Note: Make sure you don't add any extra spaces, including at the end of each line, as JavaScript is very sensitive.

Your new file will end with //--> on the last line.

Here's how your code might look:

<!-- document.writeln('<TABLE BORDER="0" ALIGN="Center">');
document.writeln('<TR>');
document.writeln('<TD>');
document.writeln('Your table content');
document.writeln('</TD>');
document.writeln('</TR>');
document.writeln('</TABLE>');
//-->

Each backslash (\) should be preceded with another backslash.

Example: \\

Each apostrophe (') should be preceded with a backslash.

Example: \'

You can include most HTML and JavaScript coding however, you cannot include JavaScript that must access another file to run.

After you've created your content and added the special JavaScript coding, you'll need to save your new file. Try to select a name that reflects your file such as navigate.js and make sure your filename is no longer than eight letters.

Next, you'll need to create a new directory on your server where you store your HTML files. Name this directory "content" (without the quotes) and upload your new .js file in ASCII.

Here's where the magic occurs... Place the following code in your HTML pages where you would like your navigate.js content to be displayed. Make sure you change the URL and direct it to your new .js file. The following code must be displayed exactly as it appears. Make sure there are no spaces after the first line of code.

<SCRIPT language="JavaScript" src="http://www.yourdomain.com/content/yourfile.js"> </SCRIPT>

If you've followed the above steps correctly, your navigational system should now be displaying on your web page. If you are receiving a script error message, most of the time, it's due to an extra space at the end of a line or an extra or missing character. Make sure you go over your code very carefully. Once you've created your content feed and it is displaying your content, updating your file will be simple.

If you'd rather not have to code the JavaScript yourself, I use a great script called, Master Syndicator which will code your content for you. I highly recommend it. www.web-source.net/cgi-bin/t.cgi?l=wm2

You can also find a free text to Javascript converter here: bontragercgi.com/Convert_Text_to_JavaScript.html

Using JavaScript to display your navigational set up can not only enable you to instantly update the content on every page of your website, but can also save you hours of valuable time.

About the Author:

Shelley Lowery is the author of the acclaimed web design course, Web Design Mastery. www.webdesignmastery.com And, Ebook Starter - Give Your Ebooks the look and feel of a REAL book. www.ebookstarter.com Visit Web-Source.net to sign up for a complimentary subscription to Etips and receive a copy of the acclaimed ebook, "Killer Internet Marketing Strategies." www.web-source.net

See more from Web Design


Other Pages You Might Enjoy...

The Meissen Porcelain Manufactory
For more than 300 years the Meissen Porcelain Manufactory has been a central figure in European porcelain. It was at Meissen that the first true hard-paste porcelain was manufactured outside of China, and the story of that accomplishment has the high drama of fiction - all the more intriguing because it is true.

Pirated Glassware that Collectors Want to Own
The 1996 discovery of what is believed to be the wreckage of Blackbeard’s ship Queen Anne’s Revenge, is providing historians and collectors new information about the fragile and transparent objects that came onto the North American Continent before arrival of the first piece of cut glass.

Collecting Antique Furniture
Of all the collectible antiques, the broad category of furniture is perhaps the most widely held and most satisfying. Frequently handed down through generations, the various chairs, tables, cabinets and other pieces are often in use, adding character and constancy to our daily lives. This guide includes an overview of the significant styles and historical periods, and other important information for collectors.

Collecting Antique Clocks and Watches
Information for collectors of antique clocks and watches. Includes a history of clock and watchmaking, an overview of styles, and important terminology.

Collecting Antique Jewelry
Embodying the wealth and treasure of bygone days, the antique jewelry pieces available today include some of the world's most valuable artifacts. Includes a history of jewelry making, an overview of the major historical periods, and a glossary of antique jewelry terminology.

Javascript Chatterbot Workshop
Home of the Do It Yourself Chatterbot Project. Has a ready to go chatterbot shell and full instructions on how to program it.

Tips for Improving Website Navigation
A business often has more than one target audience it wants to reach with its website. Different customers mean different sales appeals and a homepage needs to be able to direct visitor traffic to go to the right places to get information or make a sale.

Choosing the Right Color for Your Web Site
When people build a web site for their business (or hire a web design company to make it for them), not much thought is put into deciding what color their web site will be as most would rather focus on more important tasks like creating content, web site optimization and promotion. Most simply choose the most web-friendly colors, others use their company’s logo as base while some decide to just use their favorite color.

Designing A Website That Loads Quickly
The amount of time it takes for your website to load onto the visitor's screen is a major influence on traffic to your site. Research has shown that most internet users will leave your website if it takes more than 10 seconds to load and some potential guests will exit even faster. A quick loading website is vitally important to the success of your site.

London Is Great Destination for Music Fans
London's nightlife makes it a top destination for rock fans and pop music historians. From the crosswalk at Abbey Road to the venerable Royal Albert Hall, Great Britain is the place to go to see some of pop culture's most significant landmarks.

Expert Cautions Against Reverse Mortgages
Aging baby boomers are being aggressively marketed for long-term care insurance funded by reverse mortgages. Lawyer Frank Darras says beware. Betting your house on an insurance policy can backfire and leave you with nothing, he says.

A Longest Common Substring Function for Javascript
Here is a down and dirty Javascript function that returns the longest substring shared by two string variables.

Beginning at the Beginning - File Systems and Plain Text Files
Getting up and running with HTML, Javascript, and a host of other technologies requires an understanding of file systems and text editing tools. This page is for people who need to come up-to-speed on the basics before moving on to introductory markup and coding.

HTML For the Absolute Beginner
The intent of this tutorial is to provide a basic introduction to making web pages for the person who has never studied HTML before. Once one has worked through this material they should be able to create a bare bones HTML file and be ready to move on to learning to build web pages.




The MiFio Network

Visit cache.MiFio.com for more pages about business, technology, programming, home, travel and more.

Visit www.MiFio.com the website dedicated to antiques and collectibles.