【JS__UEditor】富文本编辑器的使用

简单实用的富文本编辑器

在ASPNet MVC传送html数据时会报 从客户端中检测到有潜在危险的Request.Form值

需要再web.config配置<httpRuntime maxRequestLength="2097151" requestValidationMode="2.0" />设置为2.0验证模式

同时在public ActionResult Edit()的Action方法上加[ValidateInput(false)]

可能出现编辑器乱码现象,把ueditor.config.js文本格式另存为utf-8

ueditor1_4_3_1

<!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>

猜你喜欢

转载自www.cnblogs.com/kikyoqiang/p/12811775.html