禁用CKEditor,用JS重新启用

发布于 2024-08-15 14:29:32 字数 231 浏览 1 评论 0原文

我有以下内容: 允许用户在 CKEditor 中写入文本的 POST 页面 查看页面,查看 CKEditor 中的文本

如何使查看页面中的 CKEditor 为只读,这意味着用户无法编辑注释中的文本?我想在视图页面中使用CKEditor的原因有2个: 1. 我可以使用 JavaScript 将编辑器从禁用状态更改为启用状态 2. 保持POST和POST中的样式相同。查看页面。

这可能吗?谢谢!

I have the following:
POST page that allows users to write text in CKEditor
VIEW Page, that views the text in CKEditor

How can I make CKEditor in the view page READ only, meaning the user can not edit the text in the note? The reason I want to use CKEditor in the view page is for 2 reasons:
1. I can use JavaScript to move the editor from disabled to enabled
2. Keep the styles the same from the POST & View page.

Is this possible? Thanks!

B

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

铃予 2024-08-22 14:29:32

不确定您是否仍在寻找答案,但这就是我所做的,它比他们建议的解决方法简单得多。

<script type="text/javascript">
        window.onload = function () {

            CKEDITOR.on("instanceReady", function (ev) {
                var bodyelement = ev.editor.document.$.body;
                bodyelement.setAttribute("contenteditable", false);


            });
            CKEDITOR.replace('editor1');
        };

    </script>

not sure if you are still looking for an answer but here is what I did and it was much simpler than the work around they suggest.

<script type="text/javascript">
        window.onload = function () {

            CKEDITOR.on("instanceReady", function (ev) {
                var bodyelement = ev.editor.document.$.body;
                bodyelement.setAttribute("contenteditable", false);


            });
            CKEDITOR.replace('editor1');
        };

    </script>
人间不值得 2024-08-22 14:29:32

检查讨论该问题的此 CKEditor 论坛条目,并且CKEditor 团队成员提供了一种解决方法。

Check this CKEditor forum entry where the issue is discussed, and a CKEditor team member provides a workaround.

浴红衣 2024-08-22 14:29:32

该线程的一个重要更新,从 3.6 开始,由以下支持:
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor .html#setReadOnly

An important update to this thread, as of 3.6 this is supported by:
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文