Tutorials » Building a WYSIWYG HTML Editor Using Only JavaScript and HTML

Introduction

Whether you're creating your own personal web site, a site for a medium sized business, or a site for a company intranet, the content management system (CMS) is one of the most important aspects of the overall design. If you're designing a web site that will constantly have new products or company news added to it, then you can be pretty sure that the person from the company who will be adding that content will have at best beginners knowledge of HTML.

So how do we overcome this problem? Well, we could offer to do the updates ourself, but that's pointless really: we're web developers, not content updaters for company web sites. We could offer some form of offline template that the company can edit and upload, but this is neither time effective nor streamlined. One last thing we could do is provide the company with a browser based WYSIWYG HTML editor similar to FrontPage or Dreamweaver.

If you're thinking that this is out of your league as a developer, then think again. Internet Explorer 5 and later supports a set of commands to facilitate complete browser based content creation. With just a couple of lines of JavaScript, we can create a truly mind-blowing WYSIWYG content editor in a matter of minutes, and that's what I'm going to show you how to do today.

To test the samples in this article, you should have preferably IE5 or IE6 (patched) installed on your PC. You don't need any fancy server side programming experience, just a bit of HTML and JavaScript. I will teach you the commands we will be using as we progress.

Contents

  1. Introduction
  2. Why a WYSIWYG editor
  3. execCommand examples
  4. Building our HTML editor
  5. Building our HTML editor (contd.)
  6. Building our HTML editor (contd.)
  7. Conclusion
 
 
  1 2 3 4 5 6 7