最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Set TinyMCE Editor Param after Initialized- Stack Overflow

programmeradmin2浏览0评论

I am trying to set the readonly parameter in tinyMCE to true after tinyMCE has been initalized. I am trying to use this with wordpress to disable the postEditor if the post has already been published. I found some sources claiming that you can call:

tinyMCE.activeEditor.execCommand(
    'mceSetAttribute',
    false,
    {name:'readonly',value:true}
);

but I have been having no luck with that and have not found a solution.

I am trying to set the readonly parameter in tinyMCE to true after tinyMCE has been initalized. I am trying to use this with wordpress to disable the postEditor if the post has already been published. I found some sources claiming that you can call:

tinyMCE.activeEditor.execCommand(
    'mceSetAttribute',
    false,
    {name:'readonly',value:true}
);

but I have been having no luck with that and have not found a solution.

Share Improve this question edited Jan 20, 2012 at 20:56 Charles 51.4k13 gold badges106 silver badges144 bronze badges asked Jan 20, 2012 at 18:51 Aramael Pena-AlcantaraAramael Pena-Alcantara 3681 gold badge3 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 17

An easier way to set this is tinyMCE.activeEditor.settings.readonly = true; But the problem here is that the readonly setting affects the way tinymce gets initialized. So setting it after tinymce is initialized won't have a big impact.

What you can do to prevent users from editing content in your editor is to set the contenteditable attribute of the editors iframe body to false:

tinymce.activeEditor.getBody().setAttribute('contenteditable', false);
发布评论

评论列表(0)

  1. 暂无评论