Search code examples
ckeditor

CKEditor does not render in Chrome


Background: I am building a blog application in which the blog content textarea field is to be replaced with CKEditor.

Issue: After i load the web page in Chrome, i get the below error with the text area disabled. "Uncaught TypeError: Cannot read property 'getComputedStyle' of undefined"

Code: Javascript:

$(document).ready(function() {
    CKEDITOR.addCss('body {font-family: "Roboto", "Helvetica", "Arial", sans-serif;}');
    var contentEditor = CKEDITOR.replace( 'blogContent' );
});

HTML:

<body>
   <textarea type="text" rows= "10" name="blogContent" id="blogContent" 
   maxlength="2000"></textarea>

   <script src="//cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script>
   <script src="/js/blog-form.js"></script>
</body>

Versions: Chrome: Version 66.0.3359.139 (Official Build) (64-bit) CKEditor: 4.9.2

I am looking for help to resolve this issue. This issues doesn't come up in other browsers - Edge and Firefox.


Solution

  • Run this code, it's working on chrome:

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
       <script src="https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script>
    
    <script>
    $(document).ready(function(){
    
    
        CKEDITOR.addCss('body {font-family: "Roboto", "Helvetica", "Arial", sans-serif;}');
        var contentEditor = CKEDITOR.replace( 'blogContent' );
    });
    </script>
    </head>
    <body>
    
    
     <textarea type="text" rows= "10" name="blogContent" id="blogContent" 
       maxlength="2000"></textarea>
    
    
    
    
    
    </body>
    </html>