随笔 - 9  文章 - 4  trackbacks - 0
<2011年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

常用链接

留言簿

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

//取fck内容的长度
function GetLength(str)
{
    var oEditor = FCKeditorAPI.GetInstance(str) ;
    var checkContent= oEditor.EditorDocument ;
    var contentLength ;

    if ( document.all )       
    {
        contentLength= checkContent.body.innerText.trim().length ;
    }
    else                   
    {
        var r = checkContent.createRange() ;
        r.selectNodeContents( checkContent.body ) ;
        contentLength= r.toString().trim().length ;
    }
return contentLength
}  

//判断是不是为空
function CheckPost(){
    if(GetLength("content")<=0)    //content为FCKeditor在页面所设的名字
    {
        alert('请输入内容');       
        return false;
    }
}

//取fck内容
function GetContent(str)
{
     var oEditor = FCKeditorAPI.GetInstance(str) ;
     return oEditor.GetXHTML();
}  

//去掉字符串的空格
String.prototype.trim = function()
{
             return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
posted on 2009-07-23 19:37 田园风光 阅读(1224) 评论(1)  编辑  收藏

FeedBack:
# re: 用js获取FCKeditor的内容和判断内容是否为空 2011-09-24 11:12 sdfgsdfgsd
sdfgsdfgs  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: