<script type="text/javascript">
<!--
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = ’/fckeditor/’ ; // ’/fckeditor/’ is the default value.
var sBasePath ='/fckeditor/';
var oFCKeditor = new FCKeditor( 'news_content') ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 400 ;
oFCKeditor.Width = 600 ;
oFCKeditor.Value = '' ;
oFCKeditor.Create() ;
//--〉
//取fck内容的长度
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 ;
}
//oEditor.InsertHtml(’’)
return iLength
}
function CheckPost(){
if(GetMessageLength("news_content")>10)
{
alert("请输入内容");
return false;
}
}
//取fck内容
function GetMessageContent(str)
{
var oEditor = FCKeditorAPI.GetInstance(str) ;
return oEditor.GetXHTML();
//document.write(oEditor.GetXHTML());
}
-->
</script>
<input type="button" id="" value="FCKTest" οnclick="CheckPost();" />
<input type="button" id="Button1" value="FCKTest1" οnclick="alert(GetMessageContent('news_content'))" />