百度編輯器動態添加內容及防止過濾樣式或其他屬性解決辦法
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> </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 配置文件 下圖添加過濾白名單