ueditor插入自定义内容和样式

UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点

 
通过UEditor提供的API接口可以很方便的读写操作内容并设置编辑器里的样式
 
页面中的脚本
<script>
    $(function () {
        init();
        _template();
    });
    function _template() {
        var html = '<ul><li>大因云屏</li><li>超高分GIS地图</li><li>KVM操作</li><li>高清输入节点</li><li>智能音箱系统</li><li>智能会议交互终端</li></ul><p class="foot"><img src="/public/images/pic10.jpg"></p><h1>指挥中心解决方案系统图</h1><img src="/public/images/pic11.jpg"><h1>大因云屏与传统系统对比图</h1><img src="/public/images/pic13.jpg">';
        if (windw.editorcontent && editorcontent.setContent) {
            editorcontent.setContent(html);//插入自定义内容到编辑器
            editorcontent.document.body.className += ' content ';
        }
    }
    //初始化
    function init() {
        //加载ueditor脚本
        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');//content为id号
        try {
            //添加自定义类名content,用于设置编辑器里的样式
            editorcontent.addListener('ready', function (editor) {
                (editorcontent.document.body.className += ' content ')
            });
            editorcontent.sync();
        } catch (err) {}
    }
    </script>

  

 
\js\ueditor\themes\iframe.css 自定义编辑器里的样式
/*可以在这里添加你自己的css*/
.content {
    padding: 20px;
    background: #f6f6f6;
}
.content img {
    width: 98%;
}

 

 
 
 
参考:





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值