2

CKEditor 4.2.1 (and 4.1.2) is randomly (doesn't happen every time) throwing a JavaScript error when performing very basic/simply interactions, like clicking in the editing area and/or typing in the editing area.

Here's my HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>My Page</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script
        type="text/javascript"
        src="/assets/js/ckeditor_4.2.1_full/ckeditor.js"></script>
    <script type="text/javascript">
        $(function(){
            CKEDITOR.replace('my_text');
        });
    </script>
</head>
<body>
    <form method="post">
        <textarea name="my_text">dfagasdf sdf<br /><br />dasf asdf</textarea>
    </form>
</body>
</html>

When clicking or typing into the editing area I see multiple errors in my console:

IE9 Console

1 Answer 1

3

Have you switched Document Mode to Quirks manually? This may be a reason (although CKEditor is supposed to work in QM and I know it does). Second thing - wrap <textarea> with <fieldset> or <p>. I've seen that it makes problems from time to time (and it's also incorrect to have textarea directly in form).

Edit: The page is running in Quirks Mode, because you've got incorrect DOCTYPE. You should have:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

Instead of:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

After fixing this, IE stops throwing this error.

PS. You shouldn't also use ISO-8859-1 encoding, which is poor and may lead to issues. Use UTF-8 instead.

4
  • No, Quirks is the default when I load the page. The same thing happens when the text area is wrapped with a fieldset tag. Why is it incorrect to have a textarea nested under a form tag? I've never heard that in my 14 years of programming. Sep 23, 2013 at 17:11
  • Uh. I've just checked that I remember this rule from XHTML. It's ok in HTML 4.01 and HTML 5, but in XHTML 1.0 Strict was an error. Dunno why. Anyway, I've just checked that this error is thrown because you're running your page in QM. When I fixed DOCTYPE which in your case is incorrect, everything started to work fine.
    – Reinmar
    Sep 23, 2013 at 18:09
  • Thanks for the updates. I'll try these changes. I've inherited a ton of quite old code, so I'm still cleaning it up. Sep 23, 2013 at 18:49
  • you're exactly right on the DOCTYPE. I hadn't realized that the DOCTYPE was setup incorrectly. Unfortunately, due to how the website was built and crappy CSS that was used, changing out of Quirks mode jacks up the layout of the website in IE8, which is what most users are using. For now, I'm going to update the encoding to UTF-8, and start a new project to update the DOCTYPE and CSS with it separately, since the client's user have yet to upgrade to IE9. Thank you. Sep 23, 2013 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.