View Full Version : Javascript WYSIWYG Help

Mar 16th, 2007, 10:14 PM
I've just started with javascript and Im trying to create simple WYSIWYG for one of my textareas. This is my code so far...

<script type="text/javascript">
function bold()
var user = prompt( "Enter Text","" );
document.content.write( "<b> " +user+ ", </b>");

Im trying to write the bold text to a textarea called content. Can anyone see where I am going wrong? Thanks...

Mar 16th, 2007, 11:59 PM
Most RTE (Rich Text Editors) make use of IFrames and execute DesignMode on the IFrame in order to execute commands such as bold, italic etc.

However, you should still be able to make use of textarea if you wish, though, most users who are unfamiliar with html may find it difficult to understand syntax, as they will be seeing <b>, or <i> and that won't mean much to them. If you wish to use a textarea, I think you need to find out about creating ranges in JavaScript, and bookmarking cursor positions in order to apply those behaviours etc.

Here is a good reference for Mozilla browsers, and the commands that you can apply etc.


The above commands can also be applied on most browsers that support DesignMode, among them is Internet Explorer, Firefox, Safari, and Opera9+

Here is one of the best open source Rich Text Editors that you can use

and here is more




Mar 17th, 2007, 12:03 AM
Looking at the links now...