您好,欢迎访问一九零五行业门户网

php kindeditor使用方法

php kindeditor使用方法:首先下载kindeditor并解压到项目中;然后删除不需要的文件夹;最后初始化kindeditor富文本编辑器即可。
推荐:《php视频教程》
下载kindeditor
可以选择去官网下载(http://kindeditor.net/down.php),不过要翻墙;或者直接csdnhttp://download.csdn.net/download/dknightl/9813052
下载解压完放入自己的项目中
在解压完后可以删除不需要的文件夹,我是删除了asp、asp.net、jsp、php,examples可以放到其他地方,用作代码参考。
初始化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('textarea[name="content"]', { resizetype : 1, allowpreviewemoticons : false, allowimageupload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); }); </script>
//默认模式 <script> var editor; kindeditor.ready(function(k) { editor = k.create('textarea[name="content"]', { allowfilemanager : true }); k('input[name=gethtml]').click(function(e) { alert(editor.html()); }); k('input[name=isempty]').click(function(e) { alert(editor.isempty()); }); k('input[name=gettext]').click(function(e) { alert(editor.text()); }); k('input[name=selectedhtml]').click(function(e) { alert(editor.selectedhtml()); }); k('input[name=sethtml]').click(function(e) { editor.html('<h3>hello kindeditor</h3>'); }); k('input[name=settext]').click(function(e) { editor.text('<h3>hello kindeditor</h3>'); }); k('input[name=inserthtml]').click(function(e) { editor.inserthtml('<strong>插入html</strong>'); }); k('input[name=appendhtml]').click(function(e) { editor.appendhtml('<strong>添加html</strong>'); }); k('input[name=clear]').click(function(e) { editor.html(''); }); }); </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]
获得内容等方法可以参考api
http://kindeditor.net/doc.php以上就是php kindeditor使用方法的详细内容。
其它类似信息

推荐信息