仿用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转义字符

最新文章

  1. 字母序列递增,即A+1=B,B+2=D,ASCII
  2. Android Activity 四种启动模式
  3. The user specified as a definer (&#39;root&#39;@&#39;%&#39;) does not exist
  4. Android开发学习---sharedpreference的使用
  5. python编码
  6. 【转】windows7 修改环境变量 和 用不用重启电脑的讨论
  7. jenkins配置记录(1)--添加用户权限
  8. Sql 2000丢失sa 密码,重置sa密码
  9. 剑指Offer26 字符串的全排列
  10. WPF 控件截图位置不正确的问题
  11. sql 常用操作脚本代码
  12. 利用LinkedList实现洗牌功能
  13. hibernate--ID生成策略--annotation
  14. Redis参数配置和运维说明
  15. Azure环境中Nginx高可用性和部署架构设计
  16. HBase shell scan 过滤器用法总结
  17. 【BZOJ1095】【ZJOI2007】捉迷藏 [动态点分治]
  18. Install rapyuta Robot Cloud Engine on Ubuntu14.04
  19. JAVAEmail工具错误java.lang.ClassNotFoundException: javax.activation.DataSource
  20. java Object类源代码详解 及native (转自 http://blog.csdn.net/sjw890821sjw/article/details/8058843)

热门文章

  1. cin.clear()、cin.sync()
  2. Vue 中 双向绑定数据
  3. Dubbo负载均衡:最少活跃数(LeastActive)
  4. Linux驱动开发10——内核环形双向链表
  5. python3 以utf-8编码写文件
  6. flex 判断对象的类型
  7. oracle-只读数据文件的备份与恢复
  8. MySQL学习-MySQL内置功能_索引与慢查询
  9. docker安装Rancher
  10. kafka学习(七)