Click here to Skip to main content
15,867,488 members
Articles / Web Development / HTML

Code Project Article Writer Helper

Rate me:
Please Sign up or sign in to vote.
4.80/5 (44 votes)
9 Aug 2003CPOL2 min read 203.4K   1.5K   87   52
Some HTML and JavaScript that helps you write and preview CP articles.
<!-- Article image -->

Sample Image - articlehelp.jpg

<!-- Add the rest of your HTML here -->

Introduction

<blink>Here is a utility you may find useful when writing articles for the Code Project[^] offline. It should cut down on your HTML formatting time plus it will give you a preview all on the same page. As far as I know, it only works in Internet Explorer.

How to Use It

There are buttons on the left of the textarea that mimic the HTML insertion on the CP forums pages. I added p (<p></p>), br (<br>), space (&nbsp;), sup (<sup></sup>), sub (<sub></sub>), H2 (<H2></H2>) and img (<img src=...>) since articles may need them.

The textarea is where you type the article, of course.

The buttons below the textarea are for normal editing of the textarea except for the preview button. Preview will show you a close approximation of how the page will look in a <div> below the buttons.

Here is some code for the preview:

JavaScript
function ShowPreview()
{
    // replace div innerHTML content
    previewarea.innerHTML = '<table border=1 width=100 
        height=100% cellpadding=0 cellspacing=0><tr>
        <td valign=top align=left>' + Form1.inputarea.value 
        + '</td></tr></table>';
}
...
<button onclick="ShowPreview()" type="button">Preview</button>
...
<div name="previewarea" id="previewarea" style="WIDTH: 100%;
    HEIGHT: 300px; BACKGROUND-COLOR: #ffffff"></div>

Conclusion

This article was created in the Article Helper, so as you can see, it seems to work OK. I hope you find it helpful.

Most of this javascript code was shamelessly stolen from the Code Project's Reply To a Message page. I hope Chris doesn't mind...

Revision History

Version 1.1

  • Updates the preview area on the OnKeyUp event of the textarea, and also after the OnClick of all relevant buttons. (Thanks for the suggestion Zek3vil!)

Version 1.2

  • Added ol, ul, and li buttons for making tables of contents.
  • Added buttons to open an HTML file, and Save the Helper text to an HTML file.

Version 1.3

  • XHTML compliant tags. (Suggested by Thomas Freudenberg)
  • Added a quot button for entering quotation marks. (" ")
  • Added a table button, plus row and column input areas to make HTML tables.
         
         
  • Added drop down list of less commonly used tags including:
    blockquote, center, cite, div, dl, dt, dd, em, H1, H3, H4, H5, H6, hr, iframe, hr, marquee, tt
    Choose a tag and click the use button to paste it into the page.

License

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


Written By
Software Developer (Senior)
United States United States
I have been a professional developer since 1996. I live in Illinois, in the USA. I am married and have four children.

Comments and Discussions

 
GeneralAccess Denied errors in Windows 7 (maybe vista too?) Pin
compninja254-Mar-10 14:22
compninja254-Mar-10 14:22 
I think this is a wonderful tool and want to say kudos! One thing I ran into was every time I tried to open or save I kept getting a javascript "access denied" error when the javascript was trying to open the window. Just incase anyone else runs into this too, I found all you need to do is supply a couple of paramaters.

Change: var tempwindow = window.open() To: var tempwindow = window.open("", "newWindow")
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.

GeneralChrome Doesn't like it. Pin
ely_bob9-Dec-09 9:12
professionalely_bob9-Dec-09 9:12 
Generalnot Firefox Pin
Michael Sync5-Nov-06 23:23
Michael Sync5-Nov-06 23:23 
GeneralArticle Helper Earthquakes Pin
Member 158707813-Dec-04 13:37
Member 158707813-Dec-04 13:37 
GeneralRe: Article Helper Earthquakes Pin
Jason Henderson13-Dec-04 16:47
Jason Henderson13-Dec-04 16:47 
GeneralMissing Functionality Pin
Bassam Abdul-Baki29-Jan-04 3:26
professionalBassam Abdul-Baki29-Jan-04 3:26 
GeneralRe: Missing Functionality Pin
Jeffrey Walton16-Dec-06 20:19
Jeffrey Walton16-Dec-06 20:19 
GeneralQuick question... Pin
BoozeBomb4-Aug-03 4:42
BoozeBomb4-Aug-03 4:42 
GeneralRe: Quick question... Pin
Jason Henderson4-Aug-03 5:12
Jason Henderson4-Aug-03 5:12 
GeneralRe: Quick question... Pin
BoozeBomb4-Aug-03 7:19
BoozeBomb4-Aug-03 7:19 
GeneralXHTML Pin
Thomas Freudenberg9-Mar-03 22:23
Thomas Freudenberg9-Mar-03 22:23 
GeneralRe: XHTML Pin
Jason Henderson4-Aug-03 5:04
Jason Henderson4-Aug-03 5:04 
GeneralRe: XHTML Pin
Thomas Freudenberg4-Aug-03 5:20
Thomas Freudenberg4-Aug-03 5:20 
GeneralRe: XHTML Pin
GilesHinton11-May-07 21:11
GilesHinton11-May-07 21:11 
GeneralVersion 1.2 is not available for DL Pin
kbuchan5-Mar-03 4:44
kbuchan5-Mar-03 4:44 
GeneralRe: Version 1.2 is not available for DL Pin
Jason Henderson5-Mar-03 4:50
Jason Henderson5-Mar-03 4:50 
GeneralRe: Version 1.2 is not available for DL Pin
kbuchan6-Mar-03 2:35
kbuchan6-Mar-03 2:35 
GeneralRe: Version 1.2 is not available for DL Pin
Jason Henderson6-Mar-03 3:00
Jason Henderson6-Mar-03 3:00 
GeneralRe: Version 1.2 is not available for DL Pin
kbuchan6-Mar-03 3:33
kbuchan6-Mar-03 3:33 
GeneralRe: Version 1.2 is not available for DL Pin
Jason Henderson11-Mar-03 10:50
Jason Henderson11-Mar-03 10:50 
GeneralMe again! Pin
Marc Clifton27-Feb-03 13:52
mvaMarc Clifton27-Feb-03 13:52 
GeneralRe: Me again! Pin
Jason Henderson27-Feb-03 14:43
Jason Henderson27-Feb-03 14:43 
GeneralRe: Me again! Pin
Marc Clifton28-Feb-03 0:26
mvaMarc Clifton28-Feb-03 0:26 
GeneralRe: Me again! Pin
Chris Maunder28-Feb-03 7:28
cofounderChris Maunder28-Feb-03 7:28 
GeneralRe: Me again! Pin
Jason Henderson1-Mar-03 17:12
Jason Henderson1-Mar-03 17:12 

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.