Make your own free website on Tripod.com

Cross-Browser Rich Text Editor Usage Documentation

Source: http://www.kevinroth.com/rte/

Basic Usage Example

In the body of your web page, insert the following:

  1. Add the following to your <form> tage: onsubmit="return submitForm();". This will call the submitForm() function which updates the hidden form fields associated with your RTE before the form is submitted. You will now have a <form> tag that looks like this:
    <form name="RTEDemo" action="demo.htm" method="post" onsubmit="return submitForm();">
  2. Add the submitForm() function to your page, and call the initRTE() function. The initRTE() function sets the global path variables and detects the current browser's capabilities. You must call this function before writing any RTEs to the page.
    <script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    	//make sure hidden and iframe values are in sync for all rtes before submitting form
    	updateRTEs();
    	
    	//change the following line to true to submit form
    	alert("rte1 = " + htmlDecode(document.RTEDemo.rte1.value));
    	return false;
    }
    
    //Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
    initRTE("./images/", "./", "", true);
    //-->
    </script>
    <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
    
  3. Create a new richTextEditor instance, optionally set command options, and build the editor. A full list of command options are below.
    <script language="JavaScript" type="text/javascript">
    <!--
    //build new richTextEditor
    var rte1 = new richTextEditor('rte1');
    rte1.html = 'here's the "\<em\>preloaded\<\/em\> \<b\>content\<\/b\>"';
    rte1.toggleSrc = false;
    rte1.build();
    //-->
    </script>
    
  4. *If retrieving a stored html string using a server-side language, make certain to use the RTESafe() server-side function on your string before writing it to the page. See server-side language demos to see how this is done.

Command Reference

To see a matrix of commands supported by each browser, click here.

All RTE options must be set prior to calling the build() method.

Option Type Default Value Description
html string "" String of html that will be preloaded in the RTE.
Example: rte1.html = 'preloaded text';
width int 540 Width of the RTE. If set below the width needed by the toolbars to render set commands, width will grow to minimum width necessary.
Example: rte1.width = 500;
height int 200 Height of the RTE.
Example: rte1.height = 100;
readOnly boolean false Makes RTE read-only.
Example: rte1.readOnly = true;
toolbar1 boolean true Sets whether toolbar1 will be displayed or not. Overrides command options contained within toolbar1. Toolbar1 contains header formatting, font types, and font sizes.
Example: rte1.toolbar1 = false;
toolbar2 boolean true Sets whether toolbar2 will be displayed or not. Overrides command options contained within toolbar2. Toolbar2 contains all other command options not in toolbar1.
Example: rte1.toolbar2 = false;
cmdFormatBlock boolean true Sets whether block formatting command is enabled or disabled.
Example: rte1.cmdFormatBlock = false;
cmdFontName boolean true Sets whether font type command is enabled or disabled.
Example: rte1.cmdFontName = false;
cmdFontSize boolean true Sets whether font size command is enabled or disabled.
Example: rte1.cmdFontSize = false;
cmdIncreaseFontSize boolean false Sets whether increase font size command is enabled or disabled. This command is only available on Gecko browsers.
Example: rte1.cmdIncreaseFontSize = true;
cmdDecreaseFontSize boolean false Sets whether decrease font size command is enabled or disabled. This command is only available on Gecko browsers.
Example: rte1.cmdDecreaseFontSize = true;
cmdBold boolean true Sets whether bold command is enabled or disabled.
Example: rte1.cmdBold = false;
cmdItalic boolean true Sets whether italic command is enabled or disabled.
Example: rte1.cmdItalic = false;
cmdUnderline boolean true Sets whether underline command is enabled or disabled.
Example: rte1.cmdUnderline = false;
cmdStrikethrough boolean false Sets whether strikethrough command is enabled or disabled.
Example: rte1.cmdStrikethrough = true;
cmdSuperscript boolean false Sets whether superscript command is enabled or disabled.
Example: rte1.cmdSuperscript = true;
cmdSubscript boolean false Sets whether subscript command is enabled or disabled.
Example: rte1.cmdSubscript = true;
cmdJustifyLeft boolean true Sets whether justify left command is enabled or disabled.
Example: rte1.cmdJustifyLeft = false;
cmdJustifyCenter boolean true Sets whether justify center command is enabled or disabled.
Example: rte1.cmdJustifyCenter = false;
cmdJustifyRight boolean true Sets whether justify right command is enabled or disabled.
Example: rte1.cmdJustifyRight = false;
cmdJustifyFull boolean false Sets whether justify full command is enabled or disabled.
Example: rte1.cmdJustifyFull = true;
cmdInsertHorizontalRule boolean true Sets whether insert horizontal rule command is enabled or disabled.
Example: rte1.cmdInsertHorizontalRule = false;
cmdInsertOrderedList boolean true Sets whether insert ordered list command is enabled or disabled.
Example: rte1.cmdInsertOrderedList = false;
cmdInsertUnorderedList boolean true Sets whether insert unordered list command is enabled or disabled.
Example: rte1.cmdInsertUnorderedList = false;
cmdOutdent boolean true Sets whether outdent command is enabled or disabled.
Example: rte1.cmdOutdent = false;
cmdIndent boolean true Sets whether indent command is enabled or disabled.
Example: rte1.cmdIndent = false;
cmdForeColor boolean true Sets whether change fore color command is enabled or disabled.
Example: rte1.cmdForeColor = false;
cmdHiliteColor boolean true Sets whether change hilight color command is enabled or disabled.
Example: rte1.cmdHiliteColor = false;
cmdInsertLink boolean true Sets whether insert link command is enabled or disabled.
Example: rte1.cmdInsertLink = false;
cmdUnlink boolean false Sets whether unlink command is enabled or disabled.
Example: rte1.cmdUnlink = true;
cmdInsertImage boolean true Sets whether insert image command is enabled or disabled.
Example: rte1.cmdInsertImage = false;
cmdInsertSpecialChars boolean true Sets whether insert special character command is enabled or disabled.
Example: rte1.cmdInsertSpecialChars = false;
cmdInsertTable boolean true Sets whether insert table command is enabled or disabled.
Example: rte1.cmdInsertTable = false;
cmdSpellcheck boolean true Sets whether spell check command is enabled or disabled.
Example: rte1.cmdSpellcheck = false;
cmdCut boolean false Sets whether cut command is enabled or disabled.
Example: rte1.cmdCut = true;
cmdCopy boolean false Sets whether copy command is enabled or disabled.
Example: rte1.cmdCopy = true;
cmdPaste boolean false Sets whether paste command is enabled or disabled.
Example: rte1.cmdPaste = true;
cmdUndo boolean false Sets whether undo command is enabled or disabled.
Example: rte1.cmdUndo = true;
cmdRedo boolean false Sets whether redo command is enabled or disabled.
Example: rte1.cmdRedo = true;
cmdRemoveFormat boolean false Sets whether remove formatting command is enabled or disabled.
Example: rte1.cmdRemoveFormat = true;
toggleSrc boolean true Sets whether toggle source command is enabled or disabled.
Example: rte1.toggleSrc = false;