UEditor 使用 获取纯文本/格式纯文本/html内容

UEditor下载、文档、拓展

http://fex.baidu.com/ueditor/

http://fex.baidu.com/ueditor/#start-start

https://www.cnblogs.com/wsn1203/p/5443047.html

1. 下载ueditor 及 jquery,然后引用

2. html中创建内容元素

3. js初始化UEditor控件

<!DOCTYPE html>
<html lang="en">
<head>

</head> 
<body id="body">
<div>
    <span style="width:580px;height:100%;border:0px;">
        <script id="editor" type="text/plain" style="width:100%;height:500px;">
        </script>    
    </span>
</div>

<script src="/js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor-utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor-utf8-jsp/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/ueditor-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
	//实例化编辑器  去除不必要的编辑功能
	var ue = UE.getEditor('editor', {
	    toolbars: [
	        ['fullscreen']//只保留全屏功能
	    ],
	    enableContextMenu:false,//禁止使用右键菜单
	    elementPathEnabled:false,//不启用底部元素路径
	    maximumWords:100000, //允许的最大字符数
	    autoHeightEnabled:false,//禁止自动高度
	});
    //获取编辑器内容
    function editorContent(){
        alert(ue.getContent());//获取编辑器html内容
        alert(ue.getPlainTxt());//获取保留换行/空格等格式的纯文本
        alert(ue.getContentTxt);//获取纯文本内容
    }
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/torpidcat/article/details/85228996
今日推荐