Home >Web Front-end >JS Tutorial >Two forms of js to determine whether the content of FCKeditor is empty_javascript skills

Two forms of js to determine whether the content of FCKeditor is empty_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:33:571107browse
形式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(/
/g,"");
content=content.replace(/

/g,"");
content=content.replace(/
/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
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn