我試圖用' lt'替換html標記'<'>''和'& gt;'在我的TinyMCE文本中做頁面回發之前。新TinyMCE的v.4.x我已經嘗試用這種方式TinyMCE在提交之前替換Html標記
function saveCallback(element_id, html, body) {
html = html.replace(/</gi, "<");
html = html.replace(/>/gi, ">");
return html;
}
function loadCallback(type, value) {
if (type == "insert_to_editor") {
value = value.replace(/</gi, "<");
value = value.replace(/>/gi, ">");
}
return value;
}
tinyMCE.init({
...
save_callback: "saveCallback",
cleanup_callback: "loadCallback"
});
:
$(function() {
tinymce.init({
language: "it",
width: 500,
height: 400,
formats: false,
menubar: false,
mode: "exact",
elements: "Testo",
setup: function (editor) {
editor.on('SaveContent', function (e) {
html = editor.getContent();
html = html.replace(/</gi, "<");
html = html.replace(/>/gi, ">");
editor.getElement().value = html;
});
}
});
});
和
隨着TinyMCE的v.3.xi可以這樣做這樣:
$(function() {
tinymce.init({
language: "it",
width: 500,
height: 400,
formats: false,
menubar: false,
mode: "exact",
elements: "Testo",
setup: function (editor) {
editor.on('submit', function (e) {
html = editor.getContent();
html = html.replace(/</gi, "<");
html = html.replace(/>/gi, ">");
editor.getElement().value = html;
});
}
});
});
但回發值總是包含html標記,頁面返回消息「一個潛在的危險Request.Fo檢測RM值」
我已經修改了這種方式,而現在它的確定 編碼: 'XML', 設置:功能(編輯){editor.on(」 SaveContent',function(e){e.content = e.content.replace(/&#39/g,''')。替換(/ &/g,'&');});} – Alex
謝謝,這非常有幫助。:D – Michael