'lo all,
After much trial and error and kind and fine help from you folks I have arrived at code that checks the height of the FCKeditor window based on its content at time of invocation:
+++++++++++++++++
/*
* checkWysiwyg()
*
* returns true/false
*/
function checkWysiwyg(instanceName)
{
//alert("checkWysiwyg(instanceName: "+instanceName+") - START");
var editor_frame = document.getElementById(instanceName+'___Frame');
if(!editor_frame) {
alert("Unable to obtain reference to WYSIWYG editor frame. Height check aborted.");
return false;
}
//Check the actual height of the WYSIWYG [FCKeditor]
// against the pre-set (i.e.: allowed) height
var allowedHeight = getAllowedHeight(editor_frame);
var actualHeight = getActualHeight(editor_frame);
//alert("checkWysiwyg(instanceName: "+instanceName+") - allowedHeight: "+allowedHeight+", actualHeight: " + actualHeight);
if(actualHeight > allowedHeight) {
alert("The '"+instanceName+"' content does not fit within the viewable area. Please correct.");
return false;
}
return true;
}
function getAllowedHeight(editor_frame)
{
return editor_frame==null? -1 : editor_frame.height;
}
function getActualHeight( editor_area )
{
var IFrameDoc = getIFrameDoc( editor_area );
if(typeof IFrameDoc == 'undefined')
return false;
return IFrameDoc.scrollHeight;
}
function getIFrameDoc( editor_frame )
{
var IFrameDoc;
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;
}
}
+++++++++++++++++
I thought maybe someone might find it useful.
Thanks all!
jon
jopaki@yahoo.com
After much trial and error and kind and fine help from you folks I have arrived at code that checks the height of the FCKeditor window based on its content at time of invocation:
+++++++++++++++++
/*
* checkWysiwyg()
*
* returns true/false
*/
function checkWysiwyg(instanceName)
{
//alert("checkWysiwyg(instanceName: "+instanceName+") - START");
var editor_frame = document.getElementById(instanceName+'___Frame');
if(!editor_frame) {
alert("Unable to obtain reference to WYSIWYG editor frame. Height check aborted.");
return false;
}
//Check the actual height of the WYSIWYG [FCKeditor]
// against the pre-set (i.e.: allowed) height
var allowedHeight = getAllowedHeight(editor_frame);
var actualHeight = getActualHeight(editor_frame);
//alert("checkWysiwyg(instanceName: "+instanceName+") - allowedHeight: "+allowedHeight+", actualHeight: " + actualHeight);
if(actualHeight > allowedHeight) {
alert("The '"+instanceName+"' content does not fit within the viewable area. Please correct.");
return false;
}
return true;
}
function getAllowedHeight(editor_frame)
{
return editor_frame==null? -1 : editor_frame.height;
}
function getActualHeight( editor_area )
{
var IFrameDoc = getIFrameDoc( editor_area );
if(typeof IFrameDoc == 'undefined')
return false;
return IFrameDoc.scrollHeight;
}
function getIFrameDoc( editor_frame )
{
var IFrameDoc;
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;
}
}
+++++++++++++++++
I thought maybe someone might find it useful.
Thanks all!
jon
jopaki@yahoo.com