我试图用' 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