Asp.net TinyMCE在提交前替换Html标记
在执行页面回发之前,我正在尝试将TinyMCE文本中的html标记“”替换为“”和“” 使用TinyMCE v.3.x,我可以这样做:Asp.net TinyMCE在提交前替换Html标记,asp.net,tinymce,Asp.net,Tinymce,在执行页面回发之前,我正在尝试将TinyMCE文本中的html标记“”替换为“”和“” 使用TinyMCE v.3.x,我可以这样做: function saveCallback(element_id, html, body) { html = html.replace(/</gi, "<"); html = html.replace(/>/gi, ">"); return html; } function loadCallbac
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;
});
}
});
});
$(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;
});
}
});
});
tinymce.init({
selector: "#MySelector",
width: ...,
height: ...,
encoding: 'xml',
setup: function (editor) { editor.on('SaveContent', function (e) { e.content = e.content.replace(/'/g, '&apos').replace(/&/g, '&'); }); }
});
函数saveCallback(元素id、html、正文){
html=html.replace(//gi,“”);
返回html;
}
函数loadCallback(类型、值){
如果(类型=“插入编辑器”){
value=value.replace(//gi,“”);
}
返回值;
}
tinyMCE.init({
...
保存回调:“保存回调”,
清除回调:“加载回调”
});
对于新的TinyMCE v.4.x,我尝试了以下方法:
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;
});
}
});
});
$(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;
});
}
});
});
tinymce.init({
selector: "#MySelector",
width: ...,
height: ...,
encoding: 'xml',
setup: function (editor) { editor.on('SaveContent', function (e) { e.content = e.content.replace(/'/g, '&apos').replace(/&/g, '&'); }); }
});
$(函数(){
tinymce.init({
语言:“it”,
宽度:500,
身高:400,
格式:false,
梅努巴:错,
模式:“精确”,
元素:“Testo”,
设置:函数(编辑器){
on('SaveContent',函数(e){
html=editor.getContent();
html=html.replace(//gi,“”);
editor.getElement().value=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;
});
}
});
});
$(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;
});
}
});
});
tinymce.init({
selector: "#MySelector",
width: ...,
height: ...,
encoding: 'xml',
setup: function (editor) { editor.on('SaveContent', function (e) { e.content = e.content.replace(/'/g, '&apos').replace(/&/g, '&'); }); }
});
$(函数(){
tinymce.init({
语言:“it”,
宽度:500,
身高:400,
格式:false,
梅努巴:错,
模式:“精确”,
元素:“Testo”,
设置:函数(编辑器){
关于('submit',函数(e){
html=editor.getContent();
html=html.replace(//gi,“”);
editor.getElement().value=html;
});
}
});
});
但是回发值始终包含html标记,并且页面返回消息“检测到潜在危险的请求。表单值”在初始化中尝试以下选项
encoding : 'xml',
setup: function (editor) {editor.on('SaveContent', function (e) {e.content = e.content.replace(/'/g, '&apos');});}
仅供参考:根据上述代码改编,参考:
对我有效:),希望有帮助。我用这种方法解决了:
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;
});
}
});
});
$(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;
});
}
});
});
tinymce.init({
selector: "#MySelector",
width: ...,
height: ...,
encoding: 'xml',
setup: function (editor) { editor.on('SaveContent', function (e) { e.content = e.content.replace(/'/g, '&apos').replace(/&/g, '&'); }); }
});
使用tinyMCE 4,使用以下事件尝试此清洁解决方案:
tinymce.init({
语言:“it”,
宽度:500,
身高:400,
格式:false,
梅努巴:错,
模式:“精确”,
元素:“Testo”,
初始化实例回调:函数(编辑器){
编辑器.on('PostProcess',函数(e){
e、 content=e.content.replace(//g,>');
});
},
});
我以这种方式进行了修改,现在可以对其进行编码:“xml”,设置:function(editor){editor.on('SaveContent',function(e){e.content=e.content.replace(/&39/g,&apos')。replace(/&;/g,&'))}谢谢,这非常有用。:D