博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

JS获取CkEditor在线编辑的内容

Posted on 2012-08-18 10:01  Wuqh  阅读(8351)  评论(0编辑  收藏  举报

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>CDeditor</title>

<--引用Ckeditor的js-->
    <script src="ckeditor/ckeditor.js" type="text/javascript"></script>
    <script type="text/javascript">
        function test()
        {

    //applicationform是ckeditor的id或者名字
            var val = CKEDITOR.instances.applicationform.getData();
            if (val.length == 0)
            {
                alert("空白");
            }
            else
            {
                alert(val);
            }
        }
    </script>
</head>
<body>
    <textarea id="applicationform" class="ckeditor" name="applicationform" rows="30" cols="20">Ckeditor内容</textarea>
    <input type="button" class="selectButton" value="获取内容" onclick="test();" />
</body>
</html>