我正在尝试获取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/