【www.gdgbn.com--js教程】
fck高度自适应插件
打开插件所在文件:/editor/plugins/autogrow/fckplugin.js
找到第65行:
window.frameelement.height = imainframesize ;
将其修改为:
代码如下:
这样就可以兼容ie和火狐浏览器了。
启用插件:
打开文件:/fckeditor/fckconfig.js
启用这两行:
fckconfig.plugins.add( "autogrow" ) ;
fckconfig.autogrowmax = 600 ;
autogrowmax是限制最高高度。可以根据需要自行设置。
function fckautogrow_check()
{
var oinnerdoc = fck.editordocument ;
var iframeheight, iinnerheight ;
if ( fckbrowserinfo.isie )
{
iframeheight = fck.editorwindow.frameelement.offsetheight ;
iinnerheight = oinnerdoc.body.scrollheight ;
}
else
{
iframeheight = fck.editorwindow.innerheight ;
iinnerheight = oinnerdoc.body.offsetheight ;
}
var idiff = iinnerheight - iframeheight ;
if ( idiff != 0 )
{
var imainframesize = window.frameelement.offsetheight ;
if ( idiff > 0 && imainframesize < fckconfig.autogrowmax )
{
imainframesize += idiff ;
if ( imainframesize > fckconfig.autogrowmax )
imainframesize = fckconfig.autogrowmax ;
}
else if ( idiff < 0 && imainframesize > fckautogrow_min )
{
imainframesize += idiff ;
if ( imainframesize < fckautogrow_min )
imainframesize = fckautogrow_min ;
}
else
return ;
window.frameelement.height = imainframesize;
window.frameelement.style.height = imainframesize+"px";
// gecko browsers use an onresize handler to update the innermost
// iframe"s height. if the document is modified before the onresize
// is triggered, the plugin will miscalculate the new height. thus,
// forcibly trigger onresize. #1336
if ( typeof window.onresize == "function" )
window.onresize() ;
}
}