Search code examples
javascriptasp.netfckeditor

fckeditor not working in firefox


var oEditor = FCKeditorAPI.GetInstance("<%=FCKeditorSelfDocument.ClientID %>");
        var oDOM = oEditor.EditorDocument;
oDOM.body.innerText = 'Hello';

it is working fine in IE and chrome but not working in firefox 3.6.4


Solution

  • IE uses document.all that's why it supports the format but there is a work around for firefox

    var oEditor = FCKeditorAPI.GetInstance("<%=FCKeditorSelfDocument.ClientID %>");
                var oDOM = oEditor.EditorDocument;
                if (document.all)
                {
    
                    oDOM.body.innerHTML = 'hello';// for IE
                }
                else //For firefox
                {
                    var geckoRange = oDOM.createRange();
                    geckoRange.selectNodeContents(oDOM.body);
                    geckoRange = 'hello';
                    oDOM.body.innerHTML = geckoRange;
                }
    

    now it work for both