Hi!
Does anyone know a simple way how to resize the editor according to editor content? When creating editor instance, I pass some html as editor value (objEditor.Value = some_html;), and now I would like to automatically set editor height big enough so that scrollbar wouldn't appear...
Any tips&tricks?
Thanks,
Dino
Does anyone know a simple way how to resize the editor according to editor content? When creating editor instance, I pass some html as editor value (objEditor.Value = some_html;), and now I would like to automatically set editor height big enough so that scrollbar wouldn't appear...
Any tips&tricks?
Thanks,
Dino
RE: Automatic height resize
RE: Automatic height resize
/**
* Resize height of (outer) editor frame to match inner height of contents
* @param fckEditor = editor instance reference
* @param min = minimum height (in pixels)
* @param max = maximum height
*/
function resizeHeightToContents(fckEditor, min, max) {
var frameHeight = fckEditor.EditorWindow.parent.innerHeight; //outer frame which includes menu bar
var editHeight = fckEditor.EditorWindow.innerHeight; //inner content frame
var contentHeight = fckEditor.EditorDocument.body.offsetHeight;
var heightDiff = contentHeight - editHeight;
if ((heightDiff < 0) && (frameHeight > min)) {
//shrink editor frame
frameHeight += heightDiff;
if (frameHeight < min) frameHeight = min;
fckEditor.EditorWindow.parent.frameElement.style.height = frameHeight;
}
else if ((heightDiff > 0) && (frameHeight < max)) {
//expand editor frame
frameHeight += heightDiff;
if (frameHeight > max) frameHeight = max;
fckEditor.EditorWindow.parent.frameElement.style.height = frameHeight;
}
}
Re: RE: Automatic height resize