FCKEditor

From Code Trash
Jump to: navigation, search

Initialize FCKEditor using javascript

The "JavaScript Integration Module" is the client side option to include FCKeditor in your web pages. It is quite easy to use and configure.

FCKEditor can be used in a page either by including using php or by javascript. Here we see how to include using javascript. I hope the other way is the most popular and most people know how to include using php.

Step 1

Suppose that the editor is installed in the /FCKeditor/ path of your web site. The first thing to do is to include the "JavaScript Integration Module" scripts inside the <HEAD> of your page, just like this:

<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>

Step 2

Now the FCKeditor class is available and ready to use. There are two ways to create an FCKeditor in you page:

Method 1: The inline method (preferred): Go to the body of your page, in the place you want the editor to be (usually inside a form) and place the following script:

<script type="text/javascript">
   var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
  oFCKeditor.Create() ;
</script>

Method 2: The TEXTAREA replacement method: In the "onload" method on your page, add the following code to replace a existing TEXTAREA in the page:

<html>
  <head>
    <script type="text/javascript">
      window.onload = function()
      {
        var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
        oFCKeditor.ReplaceTextarea() ;
      }
    </script>
  </head>
  <body>
    <textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
  </body>
</html>

Step 3

The editor is now ready to be used. Just open the page in your browser to see it at work.

More on this at http://www.e-zakat.com.my/baru/sistem/emarketing/FCKeditor/_docs/contents/001.html