Posted by: prajapatinilesh | September 1, 2012

ckeditor site. FCK editor to add formated conent from backend site to frontend site.

function setFCKFocus(fckId) {
//added this code to work with mozilla 15.
try {
var instance = CKEDITOR.instances[fckId];
if(instance) {
//var htmlContent = CKEDITOR.instances[fckId].getData();, document.getElementById(‘cke_40’));
return false;
catch(e) { }
}//End of function setFCKFocus

To work with old version of ckeditor we need set focus to editor in case of using insertHTML() method to add something into editor.

Error solved :

Error: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLDocument.execCommand]
Source File: 12296

How to create ckeditor object into child window, from its parent ckeditor present.
openerObjFound = false;
openerObj = window.opener;

if (openerObj && openerObj != 'undefined') {
    openerObjFound = true;

if (openerObjFound) { //if opener object found then only need to check whether spanid found or not.        
    var ckEditorAPIInstance =  window.opener.CKEDITOR;
} else {
    var ckEditorAPIInstance = parent.CKEDITOR;
var formSubmitedCheck = false;
try {
     var oEditor = ckEditorAPIInstance.instances[fName];
catch(e) {
     var oEditor = parent.parent.CKEDITOR.instances[fName];
     var formSubmitedCheck = true;
if (oEditor) {
else {
   alert('oEditor object is not found !');
    return false;

oEditor.insertHtml("<span> this is test </span>");

Nilesh Prajapati.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: