搜尋
首頁後端開發PHP問題php kindeditor使用方法

php kindeditor使用方法

Sep 25, 2020 pm 03:47 PM
kindeditor

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 id="Hello-nbsp-KindEditor">Hello KindEditor</h3>&#39;);
            });
            K(&#39;input[name=setText]&#39;).click(function(e) {
                editor.text(&#39;<h3 id="Hello-nbsp-KindEditor">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 id="默认模式">默认模式</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中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。