kind富文本编辑器
## 1、页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'kind.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script charset="utf-8" src="kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="kindeditor/lang/zh-CN.js"></script>
<script>
KindEditor.ready(function(K) {
window.editor = K.create('#editor_id');
});
</script>
</head>
<body>
内容:
<textarea id="editor_id" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;"></textarea><br />
</body>
</html>
2、附加kind
<link rel="stylesheet" href="${path }/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="${path }/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="${path }/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="${path }/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="${path }/kindeditor/plugins/code/prettify.js"></script>
<script>
KindEditor.ready(function(K) {
var editor1 = K.create('textarea[name="content1"]', {
cssPath : '${path }/kindeditor/plugins/code/prettify.css',
uploadJson : '${path }/kindeditor/jsp/upload_json.jsp',
fileManagerJson : '${path }/kindeditor/jsp/file_manager_json.jsp',
allowFileManager : true,
afterCreate : function() {
var self = this;
K.ctrl(document, 13, function() {
self.sync();
document.forms['example'].submit();
});
K.ctrl(self.edit.doc, 13, function() {
self.sync();
document.forms['example'].submit();
});
}
});
prettyPrint();
});
</script>
内容:
<textarea name="content1" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;"></textarea><br />
## 3、获取富文本的内容,修改前获取值
//获取kindeditor的内容
var content = $(document.getElementsByTagName("iframe")
[0].contentWindow.document.body).html()