现在的位置: 首页 > 综合 > 正文

jq操作fck

2012年01月26日 ⁄ 综合 ⁄ 共 1931字 ⁄ 字号 评论关闭

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="E6-19.aspx.cs" Inherits="Pages_Feditor_E6_19" %>

<!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 runat="server">
    <title>编辑器</title>

    <script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="/js/jquery.FCKEditor.js" type="text/javascript"></script>

    <script src="/js/myeditor/fckeditor.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <textarea id="fck" cols="0" name="fck" rows="0" style=" display:none;" ></textarea>

        <script type="text/javascript">
            $(function() {
                $('#fck').val("我是一个大苹果").fck({ path: '/js/myeditor/', toolbar: 'Custom' });
            });
            function showValue() {
                var getcontent = $.fck.content('fck', '');
            }

            function setValue() {
                var oEditor = FCKeditorAPI.GetInstance('fck');
                oEditor.SetHTML("<p>我是一个大苹果</p>");
            }

 //FCK会自动加载此函数
        function FCKeditor_OnComplete(editorInstance) {
           editorInstance.Events.AttachEvent('OnBlur', checkTextValue);
            editorInstance.Events.AttachEvent('OnKeyPress', checkTextValue);
        }
        //检查输入框的情况
        function checkTextValue() {

            var body = FCKeditorAPI.GetInstance('d_remark').EditorDocument.body;
            var introducevalue;
            if (body.innerText) {
                introducevalue = body.innerText;
            }
            else {
                introducevalue = FCKeditorAPI.GetInstance('d_remark').EditorDocument.body.textContent;
            }
           
            if (introducevalue == "") {
                alert("还没输入内容");
            }
        }

        </script>

        <input id="Button2" type="button" value="fck设定值" onclick="setValue();" />
        <input id="Button1" type="button" value="fck值" onclick="showValue();" />
    </div>
    </form>
</body>
</html>

抱歉!评论已关闭.