简单实用的富文本编辑器
需要再web.config配置<httpRuntime maxRequestLength="2097151" requestValidationMode="2.0" />
设置为2.0验证模式
可能出现编辑器乱码现象,把ueditor.config.js
文本格式另存为utf-8
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>ueditor</title>
</head>
<body>
<h1 id="text"></h1>
<!-- 加载编辑器的容器 -->
<script id="container" name="content" type="text/plain">
</script>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="../lib/ueditor1_4_3_1/ueditor.config.js"></script>
<script src="../lib/ueditor1_4_3_1/ueditor.all.min.js"></script>
<script src="../lib/ueditor1_4_3_1/lang/zh-cn/zh-cn.js"></script>
<script>
var ue = UE.getEditor(\'container\', {
autoHeightEnabled: true,
autoFloatEnabled: true,
initialFrameWidth: 800,
initialFrameHeight: 200
, wordCount: true //是否开启字数统计
, maximumWords: 300 //允许的最大字符数
, elementPathEnabled: false
, toolbars: [[\'source\', \'undo\', \'redo\', \'bold\', \'fontsize\', \'fontfamily\', \'justifyleft\', \'justifycenter\']]
});
//对编辑器的操作最好在编辑器ready之后再做
ue.ready(function () {
ue.setContent(\'hello\');
var html = ue.getContent();
console.log("======== html " + html);
var txt = ue.getContentTxt();
console.log("======== txt " + txt);
});
</script>
</body>
</html>