Posted by: prajapatinilesh | September 1, 2012

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

http://ckeditor.com/

http://ckeditor.com/demo

http://nightly.ckeditor.com/latest/ckeditor/_samples/api.html

http://ckeditor.com/whatsnew

<script>
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();
CKEDITOR.tools.callFunction(90, document.getElementById(‘cke_40’));
return false;
}
}
catch(e) { }
}//End of function setFCKFocus
</script>

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: http://siteurl.com/ckeditor/ckeditor.jsLine: 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>");

Thanks,
Nilesh Prajapati.

Leave a comment

Categories