Share on Linkin

Free Articles Archive

Change Web Page Content Dynamically

by Maggie Lietz - Copyright 2003

It's the last day of the year when you realize that the copyright date on your website needs to be changed. And, if your website merely constitutes a handful of pages, updating the copyright won't be all that difficult or time-consuming.

On the other hand, let's say you have a website with numerous pages. Or worse, several websites with numerous pages. Needless to say, changing the copyright date here, there, and everywhere would equate to a labor-intensive, time-consuming task.

And let's face it. That's definitely not something you would look forward to, especially when you'd prefer to be out there enjoying a New Year's celebration.

Fortunately, there's a method that takes all the work out of updating your web pages. It's called dynamic content and here's how it works.

First, you create a separate file (we'll call it copyright.js). Within that document, you place the actual copyright information, exactly as you want it to appear on your web pages. Next, you insert a small piece of JavaScript within your HTML code.

When it comes time to update your pages, you merely change what's in the copyright.js file and then upload the new version to your web server. Miraculously, every page of your website (where the JavaScript was inserted in the HTML code) is automatically changed to reflect the new information.

So now that we've talked about it in general terms, here are the exact instructions for setting this up, step by step.

Open a new document in Notepad (or a similar plain text editor) and type in the following:

document.write('xxxxxxxxx');

The x's are the actual content you want to appear on your page. For example, "Copyright 2000-2003". Be aware, however, that there can't be even one extra space in whatever you insert there. Just to be safe, you might want to turn off the word wrap feature to make certain the "document.write" is on one continuous line from start to finish.

When you're done, save the document. If you can't save it as copyright.js, not to worry. That can be accomplished through FTP when the file is uploaded to your web server. For right now, you can just save it with a .txt extension.

Next, insert the following JavaScript within the actual page HTML code, exactly where you want the copyright information to appear (you'll need to replace each "[" and "]" with "<" and ">" respectively).

[SCRIPT language="javascript" src="copyright.js"][/SCRIPT]

The final step is to upload both the revised web page (with the JavaScript) and the copyright.js to your web server in ASCII mode. If you saved the latter as a .txt document, transfer it through FTP first and then rename it with the .js extension right there in your FTP program.

Now let's review all the steps.

1. Type (or copy and paste) the document.write command shown above into a blank Notepad document.

2. Replace the x's with your actual copyright information (i.e., "Copyright 2000-2003").

3. Turn off "word wrap" to make certain there are no extra spaces or line breaks.

4. Save the document using a .txt extension for now.

5. Upload both documents (the HTML page and document.write file) to your web server directory via FTP in ASCII mode.

6. Change the .txt to a .js extension.

If the copyright information doesn't display on the web page, re-check your code in both files. You either typed something incorrectly or there's an extra space or line break in "document.write" that's preventing the JavaScript from working.

Assuming all went according to plan, you now have a system in place that will save you a whole lot of time and effort. And when the last day of this year rolls around, you can simply input the new date in your copyright.js document, upload the new version to your server, and you're done!

And while everyone else is scrambling to manually change the copyright date on each and every page of their website, you'll be out enjoying all the New Year festivities.

Now, that's dynamic! ;-)

Maggie Lietz
eBookHelper.com


ABOUT THE AUTHOR
Maggie Lietz specializes in writing, creating, and publishing ebooks. Plenty of valuable information about ebooks, online business, and Internet marketing is available on her website at http://www.ebookhelper.com. Professional services include website and graphic design, copywriting, and ebook cover images.

Feel free to use the above article in its entirety. All I ask is that you include my "About the Author" resource box. Thanks. Maggie Lietz

For your convenience, we provide copy-and-paste versions of this article in both HTML and plain text (opens in a separate browser window).




Autoresponder Script
All the features you really need at a price you can actually afford!

more info

FREE Ebooks!
Distribute them "as is" or customize them with your own URL and information!
more info