Click here to Skip to main content
15,886,545 members
Articles / Programming Languages / Javascript

Quick and Easy Website Editing

Rate me:
Please Sign up or sign in to vote.
1.20/5 (6 votes)
18 Nov 2006CPOL1 min read 24.6K   113   3   2
This article will show you how to quickly edit your website using nothing but JavaScript.

Sample Image - Image1.jpg

Introduction

Many times in web developing, I have come across problems having to edit 10-15 web pages every time I wanted to change something about my website. So, not knowing PHP or not wanting to use SSIs, I decided to find a workaround with JavaScript. In this article, you will learn how to separate your pages into sections and quickly and easily edit them from one small JavaScript file.

Using the code

Now, to start, create a JavaScript (.js) file and name it quick_edit. Then, make a reference to the JavaScript file by adding this to the header of your page:

HTML
<script language="JavaScript 1.3" type="text/javascript" src="quick_edit.js"></script>

Then, you will have to break your website up into sections (ones that change often). For example, Header, Side Menu, and Footer. The main content of the page usually varies between pages, so any thing that changes here will have to be done by manually editing the file.

Break your page up into sections like this:

HTML
<!--Header-->
<script type="text/javascript">
<!-- 
HeaderInsert();
//-->
</script>

You will use one of these for each section that you want to be able to edit quickly.

Finally, just create a function in your JavaScript file and add a Document.Write to it. Like this:

JavaScript
function HeaderInsert()
{
    document.write('<h1 align="center">Quick Edit Test Page</h1>');
}

The content that you want to be able to change quickly is all in the Document.Write. All content must stay on one line, no line breaks can be used (which limits the organization of your code).

Conclusion

Well, that's about it. This is a crazy work-around, but it works. I wouldn't suggest it for anything serious like a business website, but for a simple personal website, it works fine.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralSeems to be a neat ... Pin
Sceptic Mole18-Nov-06 23:47
Sceptic Mole18-Nov-06 23:47 
GeneralRe: Seems to be a neat ... Pin
MatrixCoder19-Nov-06 12:20
MatrixCoder19-Nov-06 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.