Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:33:57
Original
1088 people have browsed it
形式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
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template