• UEditor使用报错Cannot set property 'innerHTML' of undefined


    仿用UEditor的setContent的时候报错,报错代码如下Uncaught TypeError: Cannot set property ‘innerHTML’ of undefined。调试ueditor.config.js,ueditor.all.js 提示me.body is undefined。(我就纳了闷儿了!同样的使用那个行这个咋就不行,那个有body,view,这个咋就这么少!【我还查看了插件的内部函数,真是个good媛~】)错误的原因是没有等UEditor创建完成就使用UEditor的setContent函数了,可以通过如下两种代码解决 :

    1. ueditor.addListener("ready", function () { 
      ueditor.setContent('str'); 
      });
    2. ueditor.ready(function() { 
      ueditor.setContent('str'); 
      });

    ps:

     var ue = UE.getEditor('containerId');
        var a  = "<%= info.C_Introdution || '' %>";
        a = escape2Html(a);
        $("#introdution").html(a);
    
        function escape2Html(str) {
            if(str.indexOf(""")){
                str = str.replace(/"/ig,""");
            }
            var arrEntities={'"':'"','lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
            return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
        }
    
        ue.ready(function() {
            ue.setContent(a);
            ue.addListener("contentchange", function () {
                $("#introdution").html(ue.getContent());
            })
        });
    

      

     

    js转换html转义字符

  • 相关阅读:
    进程调度算法
    操作系统文件管理
    25 个精美的手机网站模板
    WEB和APP谁是互联网未来
    网站设计趋势
    百度搜索引擎中的快照及快照更新机制
    JS实现信息的显示和隐藏
    虚拟主机单线、双线、多线的区别
    Types of Entity in Entity Framework:
    DBContext
  • 原文地址:https://www.cnblogs.com/Jeremy2001/p/7442076.html
Copyright © 2020-2023  润新知