百度编辑器动态添加内容及防止过滤样式或其他属性解决办法

百度编辑器动态添加内容及防止过滤样式或其他属性解决办法

var UemyEditor = UE.getEditor('myEditor',{ toolbars:[['Source','|', 'fontfamily', 'fontsize', 'forecolor', 'Bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright','insertorderedlist', 'insertunorderedlist', 'inserttable']], wordCount:false, elementPathEnabled:false, initialFrameHeight:300 }); 
//设置编辑器内容: UemyEditor.ready(function() {     //UemyEditor.execCommand( 'inserthtml', CreateLxrHtml($starttime, $mstext));     UemyEditor.setContent(CreateLxrHtml($starttime, $mstext)); }); 这是要动态添加的HTML代码 如果不配置白名单百度编辑器会过滤到当中的样式或其他属性 function CreateLxrHtml(mstime='', mstext='初试'){     var HTML = '';     HTML +='<div style="font-size: 14px;font-family: Arial,\'宋体\';">';     HTML +='<div>';     HTML +='<p>{yun:}$proinfo.str_name{/yun},您好,</p>';     HTML +='<span>以下面试已被改约,请在面试后提交面试反馈,谢谢! </span>';     HTML +='<table cellpadding="8" style="font-size: 14px;font-family: Arial,\'宋体\';border: 1px solid #000;border-collapse: collapse;">';     HTML +='<tbody>';     HTML +='<tr class="tb_th" style="text-align: left;;border: 1px solid #000;">';     HTML +='<th style="border: 1px solid #000;">候选人</th>';     HTML +='<th style="border: 1px solid #000;">职位</th>';     HTML +='<th style="border: 1px solid #000;">面试进展</th>';     HTML +='<th style="border: 1px solid #000;">面试时间</th>';     HTML +='</tr>';     HTML +='<tr style="border: 1px solid #000;">';     HTML +='<td style="border: 1px solid #000;">{yun:}$can_info.chinesename{/yun}</td>';     HTML +='<td style="border: 1px solid #000;">#{yun:}$proinfo.pro_id{/yun} {yun:}$proinfo.pro_title{/yun}</td>';     HTML +='<td style="border: 1px solid #000;">'+mstext+'</td>';     HTML +='<td style="border: 1px solid #000; ">改约后:'+mstime+'<br />';     HTML +='<p style="text-decoration: line-through;">改约前:{yun:}date('Y-m-d H:i', $info.start_time){/yun}</p></td>';     HTML +='</tr>';     HTML +='</tbody>';     HTML +='</table>';     HTML +='<div>&nbsp;</div>';     HTML +='</div>';     HTML +='</div>';     HTML +='<p><br />';     HTML +='<span style="font-family: Arial, Helvetica, sans-serif">Best Regards,<br />';     HTML +='<br />';     HTML +='<b>{yun:}$user_info[0].username{/yun}</b><br />';     HTML +='<span style="color: #7f7f7f;">{yun:}$user_info[0].group_name{/yun}<br />';     HTML +='MP: {yun:}$user_info[0].mobile{/yun}<br />';     HTML +='Website: </span></span></p>';     return HTML; }  百度编辑器ueditor.config.js 配置文件 下图添加过滤白名单 

猜你喜欢

转载自www.cnblogs.com/heiliang/p/9156005.html