百度编辑器添加监控内容改变事件,不要放在editor.read()里面
2014-11-10 17:45
495 查看
百度编辑器添加监控内容改变事件,不要放在editor.read(function(){ })里面,否则显示内容时,没有上面的工具栏,要在编辑器里按个空格符什么的才出来
function add_change_listener(shellId){
//编辑内容改变监听事件
//var shellId = 'container';
// editor.addListener("contentChange",function(){
// console.log('内容改变:'+editor.getContent());
// });
//一般的字符都可以监听,但是@#¥%……这些字符的输入是监听不到的。所以采用如下的方法:
//参考帖子:http://www.cnblogs.com/longze/archive/2013/07/17/3195564.html
$('#' + shellId + ' #edui1_toolbarbox').css('display','none');
editor.fireEvent("contentChange");
var $textarea = $('#' + shellId + '').parent().find('iframe').contents();
var fn = function(){
g_content_changed = true;
console.log('content_changed1, g_content_changed='+g_content_changed);
}
if (document.all) {
$textarea.get(0).attachEvent('onpropertychange',function(e) {
fn();
});
}else{
$textarea.on('input',fn);
$textarea.on('keyup',fn);
}
}
function add_change_listener(shellId){
//编辑内容改变监听事件
//var shellId = 'container';
// editor.addListener("contentChange",function(){
// console.log('内容改变:'+editor.getContent());
// });
//一般的字符都可以监听,但是@#¥%……这些字符的输入是监听不到的。所以采用如下的方法:
//参考帖子:http://www.cnblogs.com/longze/archive/2013/07/17/3195564.html
$('#' + shellId + ' #edui1_toolbarbox').css('display','none');
editor.fireEvent("contentChange");
var $textarea = $('#' + shellId + '').parent().find('iframe').contents();
var fn = function(){
g_content_changed = true;
console.log('content_changed1, g_content_changed='+g_content_changed);
}
if (document.all) {
$textarea.get(0).attachEvent('onpropertychange',function(e) {
fn();
});
}else{
$textarea.on('input',fn);
$textarea.on('keyup',fn);
}
}
相关文章推荐
- 百度编辑器的内容改变事件监听bug
- 百度编辑器的内容改变事件监听bug
- 为ckeditor添加事件,并得到ckeditor中的内容,点击重置使编辑器置空
- Easyui的datagrid的行编辑器Editor中添加事件(修改某个单元格带出其他单元格的值)
- jquery给net里面的RadioButtonList添加选项改变事件
- 为什么使用百度编辑器时 前台代码不能放在 class<table >中 如果放进去的话,会发生 百度编辑的内容显示不出来
- 百度编辑器改变内容
- 为UEditor(百度编辑器)增加监听事件,自动提取内容为摘要
- java文本框内容改变事件以及改变文本框内容
- CuteEditor 编辑器添加中文字体
- VS2005出现无法在DialogEditor里面为控件添加变量和事件句柄
- 如何利用js取得eWebEditor编辑器的内容
- 设置鼠标移动到DIV里面的内容上面 DIV标签改变背景色
- 百度搜索"W"结果内容全部为黄色网站地址;百度搜索w,然后翻第二页结果内容低俗;百度继被黑之后再次陷入“W搜索门”事件(图片)
- 关于VS2008里面的FormClosing事件内添加对话框后重复执行的问题
- 捕获input 文本框内容改变的事件
- 捕获input文本框内容改变事件的js代码
- onchange 事件会在域的内容改变时发生。
- 怎么给Datagridview里面的控件添加事件
- Asp.net中在GridView数据绑定事件中改变显示内容要注意的问题