Use JavaScript to Dynamically Update Your Website (Part 1 of 2)
Category: Website Design and Development | Date: 2003-10-05 |
If youve been on the Internet for a while, youve 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 youd like to see an example of a navigational system that
is dynamically displayed, visit http://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 , etc. as you are only
creating the feed for one section of your existing web page which already has
those tags.
Once youve created your new page containing your navigational HTML, youll 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
");" (without the beginning and ending quotes). Your first line of
HTML will be placed between the beginning and ending coding. For every line of
your original coding, youll need to add the above-mentioned codes before and
after.
Note: Make sure you dont add any extra spaces, including at the end of each
line, as JavaScript is very sensitive. Your new file will end with file://-- on
the last line.
Heres how your code might look:
Please note: The following code should be enclosed with < at the beginning of
the first line and > at the end of the last line. These brackets have been
removed to enable you to view the code properly.
!--
document.writeln();
document.writeln(
);
file://--
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.
After youve created your content and added the special JavaScript coding,
youll 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, youll 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.
Heres where the magic occurs... Place the following code in your HTML page
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.
Note: The above code should only take two lines. The first line will contain
. The above example may not display
correctly through your email program.
If youve 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, its 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 youve
created your content feed and it is displaying your content, updating your file
will be simple.
If youd rather not have to code the JavaScript yourself, I use a great script
called, Master Syndicator which will code your content for you.
http://willmaster.com/master/
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 Webmaster of Web-Source.net - A complete resource portal
for the Internet entrepreneur. The site assists the entrepreneur in developing a
serious Web presence by providing a wealth of free information, resources, tools
and content.
Shelley Lowery
service@web-source.net
http://www.web-source.net
); document.writeln(Your table content); document.writeln( | ); document.writeln(
service@web-source.net
http://www.web-source.net
Copyright © 2005-2006 Powered by Custom PHP Programming