我正试图获得tinymce编辑器的宽度和高度。
我正在尝试使用富文本编辑器设置textarea的宽度和高度。
尝试使用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');
}
});
}
答案 0 :(得分:1)
如果编辑器的高度和宽度已在tinymce配置中设置,您可以使用
从那里获取这些设置tinymce.get('post_content').getParam('height');
和
tinymce.get('post_content').getParam('width');
答案 1 :(得分:0)
您确定在执行了该功能后执行该功能吗? Couse这适合我:
$("#content_ifr").width()
当我在此页面的控制台中执行上述代码时,我得到682: http://www.tinymce.com/tryit/jquery_version.php
答案 2 :(得分:0)
$(tinyMCE.activeEditor.getContainer()).height()