How to use CKEditor in your web page using JavaScript

CKEditor has replaced its older version FCKEditor with more features and enhanced browser compatibility with latest versions of Firefox and Chrome. It’s also more secure than FCKEditor which has been exploited by hackers several times in the past.

Use the following JavaScript code to instantiate CKEditor on a web page

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">if (typeof jQuery == 'undefined') google.load("jquery", "1");</script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
$('textarea').each(function() {
CKEDITOR.replace($(this).attr('name'),
{
coreStyles_underline : { element : 'u' },
width : 760,
language: 'en'
});
});
});
//--></script>

Add the above code in the <head> section of your web page. The code assumes that you have copied the CKEditor folder where the web page resides. If the CKEditor resides in another folder then please make changes to the path in the above code snippet.

Comments?

Leave a Comment