jquery - 如何获取宽度、高度或tinymce编辑器

标签 jquery tinymce

我正在尝试获取tinymce编辑器的宽度和高度。

我正在尝试设置适合富文本编辑器的文本区域的宽度和高度。

尝试使用 jquery,但默认仅返回 width=100px :|

setup : function(ed) {
        // Add a custom button
        ed.addButton('bbcodemode', {
            title : 'View BBcode source',
            image : '{link}/tiny_mce/themes/advanced/img/bbcodemode.gif',
            onclick : function() {
                $.ajax({
                    type: "POST",
                    url: "{link}/htmltobbcode/",
                    data: "ctn="+encodeURIComponent(tinyMCE.activeEditor.getContent()),
                    success: function(msg){
                        $('#post_content').val(msg);
                        //tinyMCE.activeEditor.setContent(msg);


                    }
                });

                alert($('#post_content_ifr').width());
                $('#post_content').css("width",$('#post_content_ifr').width());
                $('#post_content').css("height",$('#post_content_ifr').height());

                // Add you own code to execute something on click
                tinyMCE.execCommand('mceToggleEditor',false,'post_content');


            }
        });
    }

最佳答案

如果编辑器的高度和宽度已在tinymce配置中设置,您可以使用从那里获取这些设置

tinymce.get('post_content').getParam('height');

tinymce.get('post_content').getParam('width');

关于jquery - 如何获取宽度、高度或tinymce编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9772318/

相关文章:

javascript - 带有 ReactJs 的 TinyMCE - onChange 事件只触发一次

javascript - TinyMCE 替换父节点

jquery - 循环浏览每个输入时从 select 获取文本

带有基本 jquery ui 插件的 IE6 中的 javascript 内存泄漏

javascript - 如何将纯文本之类的html附加到页面

javascript - tinyMCE 模糊事件

javascript - Google Places 自动完成下拉菜单不可见

javascript - 如何将 promise 重定向到现有的延期?

django - 错误 : No module named tinymce

php - 如何从 DOM 中选择一个tinyMCE WYSIWYG?