Javascript 无论config.height等于什么,主电源的大小都相同。即使它会更新,我是否也需要根据顶部的高度来更改值(我似乎无法通过编程实现)?我刚刚删除了我的第一个新答案。在CKE文档中找到它并不是那么容易谢谢你的发帖,但我想我在我的原始信息中有点不清楚。我希望
Javascript 无论config.height等于什么,主电源的大小都相同。即使它会更新,我是否也需要根据顶部的高度来更改值(我似乎无法通过编程实现)?我刚刚删除了我的第一个新答案。在CKE文档中找到它并不是那么容易谢谢你的发帖,但我想我在我的原始信息中有点不清楚。我希望,javascript,jquery,css,ckeditor,ckeditor4.x,Javascript,Jquery,Css,Ckeditor,Ckeditor4.x,无论config.height等于什么,主电源的大小都相同。即使它会更新,我是否也需要根据顶部的高度来更改值(我似乎无法通过编程实现)?我刚刚删除了我的第一个新答案。在CKE文档中找到它并不是那么容易谢谢你的发帖,但我想我在我的原始信息中有点不清楚。我希望在调整窗口大小时动态更改文本区域高度,同时保持整个编辑器高度不变。查看我的编辑了解更多信息。再次更新。。。看一看我想我明白了。感谢您的帮助:)我已经解决了我最初的问题,但我现在想知道如何在不绑定“单击”或“调整大小”之类的事件的情况下访问动态添
无论config.height等于什么,主电源的大小都相同。即使它会更新,我是否也需要根据顶部的高度来更改值(我似乎无法通过编程实现)?我刚刚删除了我的第一个新答案。在CKE文档中找到它并不是那么容易谢谢你的发帖,但我想我在我的原始信息中有点不清楚。我希望在调整窗口大小时动态更改文本区域高度,同时保持整个编辑器高度不变。查看我的编辑了解更多信息。再次更新。。。看一看我想我明白了。感谢您的帮助:)我已经解决了我最初的问题,但我现在想知道如何在不绑定“单击”或“调整大小”之类的事件的情况下访问动态添加的DOM元素。我使用“load”和“ready”尝试了类似于上面的代码,但这两种代码似乎都不起作用。我已经解决了最初的问题,但我现在想知道如何访问动态添加的DOM元素,而不必绑定到“click”或“resize”之类的事件。我尝试过使用“load”和“ready”编写类似于上面的代码,但这两种代码似乎都不起作用。
config.height = 400;
config.autoGrow_minHeight = 200;
<div id="cke_rawText">
<span id="cke_rawText-arialbl"></span>
<div class="cke_inner cke_reset">
<span id="cke_1_top"></span>
<div id="cke_1_contents"></div>
<span id="cke_1_bottom"></span>
</div>
</div>
$(window).resize (function(event) {
event.preventDefault();
var i = parseInt($('.cke_inner').css("height"));
var t = parseInt($('#cke_1_top').css("height")) + 9;
var b = parseInt($('#cke_1_bottom').css("height")) + 9;
var m = i - t - b;
$('#cke_1_contents').css({"height" : m});
});
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1', {
height : 200,
autoGrow_minHeight : 200,
on:{
resize: function(){
$("#msg").html("CKEditor resized!");
$("#2nd").html("This is a different event!");
}
}
});
var cke_1_top_Width_memory;
window.onresize = function(e) {
$("#msg").html("Window resized!");
cke_1_top_Width = $(document).find("#cke_1_top").css("width");
console.log("");
console.log("onresize fct begin, cke_1_top_Width_memory: "+cke_1_top_Width_memory); // undefined on the first pass.
// If previous value is different, change the CKE editable zone height
if(cke_1_top_Width!=cke_1_top_Width_memory){
console.log("CKE Height is changing!");
// Calculate difference between the 2 values
diff=parseInt(cke_1_top_Width_memory)-parseInt(cke_1_top_Width);
cke_1_contents = parseInt($(document).find("#cke_1_contents").css("height"));
console.log("cke_1_contents height: "+cke_1_contents+"px");
New_cke_1_contents = cke_1_contents+((diff*16)/4)+"px"; // assuming 16 px is something like on line... For each 4 px lost on width.
// To ensure a minimal height
if(New_cke_1_contents<"200px"){
New_cke_1_contents="200px";
}
$(document).find("#cke_1_contents").css({"height":New_cke_1_contents});
after = $(document).find("#cke_1_contents").css("height");
console.log("cke_1_contents height - after: : "+after);
}
// update mem
cke_1_top_Width_memory = cke_1_top_Width;
console.log("onresize fct end, cke_1_top_Width_memory: "+cke_1_top_Width);
//$("#CKform").css({"top":"30%"});
$("#2nd").html("Also try to resize CKEditor by dragging it's bottom-right corner");
};
$(window).resize (function(event) {
event.preventDefault();
var i = parseInt($('.cke_inner').css("height"));
var t = parseInt($('#cke_1_top').css("height")) + 9;
var b = parseInt($('#cke_1_bottom').css("height")) + 9;
var m = i - t - b;
$('#cke_1_contents').css({"height" : m});
});