PDA

View Full Version : Javascript WYSIWYG Help



mbrown174
Mar 16th, 2007, 10:14 PM
Hello,
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>");
}</script>

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

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

http://www.mozilla.org/editor/midas-spec.html

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
http://www.fckeditor.net/

and here is more

http://www.webwizguide.info/asp/sample_scripts/RTE_application.asp

http://dojotoolkit.org/docs/rich_text.htmlhttp://dojotoolkit.org/docs/rich_text.html

Cheers,
Ess

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