UEditor使用报错Cannot set property 'innerHTML' of undefined
2024-09-05 10:53:52
仿用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函数了,可以通过如下两种代码解决 :
ueditor.addListener("ready", function () {
ueditor.setContent('str');
});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());
})
});
最新文章
- 字母序列递增,即A+1=B,B+2=D,ASCII
- Android Activity 四种启动模式
- The user specified as a definer (&#39;root&#39;@&#39;%&#39;) does not exist
- Android开发学习---sharedpreference的使用
- python编码
- 【转】windows7 修改环境变量 和 用不用重启电脑的讨论
- jenkins配置记录(1)--添加用户权限
- Sql 2000丢失sa 密码,重置sa密码
- 剑指Offer26 字符串的全排列
- WPF 控件截图位置不正确的问题
- sql 常用操作脚本代码
- 利用LinkedList实现洗牌功能
- hibernate--ID生成策略--annotation
- Redis参数配置和运维说明
- Azure环境中Nginx高可用性和部署架构设计
- HBase shell scan 过滤器用法总结
- 【BZOJ1095】【ZJOI2007】捉迷藏 [动态点分治]
- Install rapyuta Robot Cloud Engine on Ubuntu14.04
- JAVAEmail工具错误java.lang.ClassNotFoundException: javax.activation.DataSource
- java Object类源代码详解 及native (转自 http://blog.csdn.net/sjw890821sjw/article/details/8058843)