php kindeditor使用方法

PHPz
發布: 2023-03-05 22:40:02
原創
2234 人瀏覽過

php kindeditor使用方法:先下載kindeditor並解壓縮到專案中;然後刪除不需要的資料夾;最後初始化kindeditor富文本編輯器即可。

php kindeditor使用方法

推薦:《PHP影片教學

  1. 下載kindeditor
    可以選擇到官網下載(http://kindeditor.net/down.php),但要翻牆;或直接CSDNhttp://download .csdn.net/download/dknightl/9813052

  2. 下載解壓縮完放入自己的專案中
    在解壓縮完後可以刪除不需要的資料夾,我是刪除了aspasp.netjspphpexamples可以放到其他地方,當程式碼參考。
    php kindeditor使用方法

  3. 初始化kindeditor富文本編輯器


  • 首先匯入下面css和js檔案

<link rel="stylesheet" href="../themes/default/default.css" />
<script charset="utf-8" src="../kindeditor-min.js"></script>
<script charset="utf-8" src="../lang/zh_CN.js"></script>
登入後複製
  • 然後初始化(textarea 為富文本編輯器主題,script程式碼初始化)

<textarea id="mul_input" name="content" style="width:700px;height:200px;visibility:hidden;display: block;">KindEditor</textarea>
 
<script>
    //简单模式初始化
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create(&#39;textarea[name="content"]&#39;, {
            resizeType : 1,
            allowPreviewEmoticons : false,
            allowImageUpload : false,
            items : [                    &#39;fontname&#39;, &#39;fontsize&#39;, &#39;|&#39;, &#39;forecolor&#39;, &#39;hilitecolor&#39;, &#39;bold&#39;, &#39;italic&#39;, &#39;underline&#39;,                    &#39;removeformat&#39;, &#39;|&#39;, &#39;justifyleft&#39;, &#39;justifycenter&#39;, &#39;justifyright&#39;, &#39;insertorderedlist&#39;,                    &#39;insertunorderedlist&#39;, &#39;|&#39;, &#39;emoticons&#39;, &#39;image&#39;, &#39;link&#39;]
        });
    });    </script>
登入後複製

php kindeditor使用方法

//默认模式        <script>
        var editor;
        KindEditor.ready(function(K) {
            editor = K.create(&#39;textarea[name="content"]&#39;, {
                allowFileManager : true
            });
            K(&#39;input[name=getHtml]&#39;).click(function(e) {
                alert(editor.html());
            });
            K(&#39;input[name=isEmpty]&#39;).click(function(e) {
                alert(editor.isEmpty());
            });
            K(&#39;input[name=getText]&#39;).click(function(e) {
                alert(editor.text());
            });
            K(&#39;input[name=selectedHtml]&#39;).click(function(e) {
                alert(editor.selectedHtml());
            });
            K(&#39;input[name=setHtml]&#39;).click(function(e) {
                editor.html(&#39;<h3>Hello KindEditor</h3>&#39;);
            });
            K(&#39;input[name=setText]&#39;).click(function(e) {
                editor.text(&#39;<h3>Hello KindEditor</h3>&#39;);
            });
            K(&#39;input[name=insertHtml]&#39;).click(function(e) {
                editor.insertHtml(&#39;<strong>插入HTML</strong>&#39;);
            });
            K(&#39;input[name=appendHtml]&#39;).click(function(e) {
                editor.appendHtml(&#39;<strong>添加HTML</strong>&#39;);
            });
            K(&#39;input[name=clear]&#39;).click(function(e) {
                editor.html(&#39;&#39;);
            });
        });        </script>
</head>
<body>
    <h3>默认模式</h3>
    <form style="margin: 0;">
        <textarea name="content" style="width:800px;height:400px;visibility:hidden;display: block;">KindEditor</textarea>
        <p>
            <input type="button" name="getHtml" value="取得HTML" />
            <input type="button" name="isEmpty" value="判断是否为空" />
            <input type="button" name="getText" value="取得文本(包含img,embed)" />
            <input type="button" name="selectedHtml" value="取得选中HTML" />
            <br />
            <br />
            <input type="button" name="setHtml" value="设置HTML" />
            <input type="button" name="setText" value="设置文本" />
            <input type="button" name="insertHtml" value="插入HTML" />
            <input type="button" name="appendHtml" value="添加HTML" />
            <input type="button" name="clear" value="清空内容" />
            <input type="reset" name="reset" value="Reset" />
        </p>
    </form>
</body>[object Object]
登入後複製
  1. 取得內容等方法可以參考API
    http://kindeditor.net/doc.php

以上是php kindeditor使用方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!