js判断FCKeditor内容是否为空的两种形式
人气:0
形式1:
function checkFCK(key)
{
var oEditor=FCKeditorAPI.GetInstance(key);
var content=oEditor.GetXHTML(true);
content=content.replace(/ /g,"");
content=content.replace(/\s/g,"");
content=content.replace(/ /g,"");
content=content.replace(/<br\/>/g,"");
content=content.replace(/<p><\/p>/g,"");
content=content.replace(/<div><\https://img.qb5200.com/download-x/div>/g,"");
if(content==null||content==""){
oEditor.SetHTML("");
return false;
}
return true;
}
形式2:
function GetMessageLength(str)
{
var oEditor = FCKeditorAPI.GetInstance(str) ;
var oDOM = oEditor.EditorDocument ;
var iLength ;
if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
return iLength
}
复制代码 代码如下:
function checkFCK(key)
{
var oEditor=FCKeditorAPI.GetInstance(key);
var content=oEditor.GetXHTML(true);
content=content.replace(/ /g,"");
content=content.replace(/\s/g,"");
content=content.replace(/ /g,"");
content=content.replace(/<br\/>/g,"");
content=content.replace(/<p><\/p>/g,"");
content=content.replace(/<div><\https://img.qb5200.com/download-x/div>/g,"");
if(content==null||content==""){
oEditor.SetHTML("");
return false;
}
return true;
}
形式2:
复制代码 代码如下:
function GetMessageLength(str)
{
var oEditor = FCKeditorAPI.GetInstance(str) ;
var oDOM = oEditor.EditorDocument ;
var iLength ;
if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
return iLength
}
加载全部内容