当使用 jQuery 加载 TinyMCE 时,这个问题可以这样解决:
1- 在您的文本区域中,在内联样式属性中指定高度:
<textarea style="height:200px;" class="tinymce" name="myfield"></textarea>
2-在实例化 TinyMCE 编辑器时添加回调函数。例如tinymceLoaded
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : 'PATH_TO_TINYMCE.js',
// General options ...
// Theme options...
// callback function
init_instance_callback : "tinymceLoaded"
});
3- 在 tinymceLoaded 函数中设置编辑器的高度:
function tinymceLoaded(inst){
// get the desired height of the editor
var height = $('#' + inst.editorId).height();
// when the editor is hidden, the height calculated is 0
// Lets use the inline style text to solve this problem
if(height == 0){
height = $('#' + inst.editorId).css('height'); // 200px
height = height.replace(/[^0-9]/g, ""); // remove all non-numeric characters to isolate the '200'
}
// set the height of the hidden TinyMCE editor
$('#' + inst.editorId + '_ifr').css({height: height + 'px'});
}