Click here to Skip to main content
Click here to Skip to main content

Quick and Easy Website Editing

, 18 Nov 2006
Rate this:
Please Sign up or sign in to vote.
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:

<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:

<!--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:

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)

About the Author

MatrixCoder
Software Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralSeems to be a neat ... PinmemberSceptic Mole18-Nov-06 23:47 
GeneralRe: Seems to be a neat ... PinmemberMatrixCoder19-Nov-06 12:20 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 19 Nov 2006
Article Copyright 2006 by MatrixCoder
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid