Click here to Skip to main content
14,880,852 members
Articles / Programming Languages / Javascript
Posted 18 Nov 2006


3 bookmarked

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
This article will show you how to quickly edit your website using nothing but JavaScript.

Sample Image - Image1.jpg


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:

<script type="text/javascript">

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).


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.


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


About the Author

Software Developer
United States United States
No Biography provided

Comments and Discussions

GeneralSeems to be a neat ... Pin
Sceptic Mole18-Nov-06 23:47
MemberSceptic Mole18-Nov-06 23:47 
GeneralRe: Seems to be a neat ... Pin
MatrixCoder19-Nov-06 12:20
MemberMatrixCoder19-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.