I have some code that does just this thing. Just trying to tweak it so it rejudges the size of the box when you change the content but this is it so far. Hope it is useful
########################## function FCKeditor_OnComplete( FCK ) { var win=null;
function change_Iframe_size( FCK ){ var name = FCK.Name; var height = testIFrameDocHeight(name); editor_frame = document.getElementById(name+'___Frame'); if (editor_frame!=null) { editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea'); var test = getIFrameDocHeight(name); editor_frame.height=test +20; editor_source.height=test +5; } } }
function getIFrameDoc( instanceName ) { var IFrameDoc; var Height; var editor_frame = document.getElementById(instanceName+'___Frame'); var IFrameObj = editor_frame.contentWindow.document.getElementById('eEditorArea');
if (IFrameObj.contentDocument) { // For NS6 IFrameDoc = IFrameObj.contentDocument; } else if (IFrameObj.contentWindow) { // For IE5.5 and IE6 IFrameDoc = IFrameObj.contentWindow.document; } else if (IFrameObj.document) { // For IE5 IFrameDoc = IFrameObj.document; } else { return false; }
/* * gets the height of an iframe document */ function getIFrameDocHeight( name ) { var IFrameDoc = getIFrameDoc( name ); if(typeof IFrameDoc == 'undefined') return false; return IFrameDoc.scrollHeight; }
function testIFrameDocHeight(name){ editor_frame = document.getElementById(name+'___Frame'); if (editor_frame!=null) { editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea'); var test = getIFrameDocHeight(name); return test; } return 0; }
function setIFrameDocHeight(name){ editor_frame = document.getElementById(name+'___Frame'); if (editor_frame!=null) { editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea'); var test = getIFrameDocHeight(name); alert(test); editor_frame.height=test+20; editor_source.height=test+5; } }
RE: Check for window height of fckeditorarea.
##########################
function FCKeditor_OnComplete( FCK ) {
var win=null;
if (FCK.Name=="FCKToolbar") {
}
else {
win = window.frames[FCK.Name+"___Frame"];
change_Iframe_size( FCK );
}
}
function change_Iframe_size( FCK ){
var name = FCK.Name;
var height = testIFrameDocHeight(name);
editor_frame = document.getElementById(name+'___Frame');
if (editor_frame!=null) {
editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea');
var test = getIFrameDocHeight(name);
editor_frame.height=test +20;
editor_source.height=test +5;
}
}
}
function getIFrameDoc( instanceName ) {
var IFrameDoc;
var Height;
var editor_frame = document.getElementById(instanceName+'___Frame');
var IFrameObj = editor_frame.contentWindow.document.getElementById('eEditorArea');
if (IFrameObj.contentDocument) {
// For NS6
IFrameDoc = IFrameObj.contentDocument;
} else if (IFrameObj.contentWindow) {
// For IE5.5 and IE6
IFrameDoc = IFrameObj.contentWindow.document;
} else if (IFrameObj.document) {
// For IE5
IFrameDoc = IFrameObj.document;
} else {
return false;
}
if(typeof IFrameDoc.body != 'undefined')
{
return IFrameDoc.body;
}
else
{
return IFrameDoc.documentElement;
}
}
/*
* gets the height of an iframe document
*/
function getIFrameDocHeight( name )
{
var IFrameDoc = getIFrameDoc( name );
if(typeof IFrameDoc == 'undefined')
return false;
return IFrameDoc.scrollHeight;
}
function testIFrameDocHeight(name){
editor_frame = document.getElementById(name+'___Frame');
if (editor_frame!=null) {
editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea');
var test = getIFrameDocHeight(name);
return test;
}
return 0;
}
function setIFrameDocHeight(name){
editor_frame = document.getElementById(name+'___Frame');
if (editor_frame!=null) {
editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea');
var test = getIFrameDocHeight(name);
alert(test);
editor_frame.height=test+20;
editor_source.height=test+5;
}
}