Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net TinyMCE在提交前替换Html标记_Asp.net_Tinymce - Fatal编程技术网

Asp.net TinyMCE在提交前替换Html标记

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, "&lt;"); html = html.replace(/>/gi, "&gt;"); return html; } function loadCallbac

在执行页面回发之前,我正在尝试将TinyMCE文本中的html标记“”替换为“”和“”

使用TinyMCE v.3.x,我可以这样做:

function saveCallback(element_id, html, body) {
    html = html.replace(/</gi, "&lt;");
    html = html.replace(/>/gi, "&gt;");
    return html;
}

function loadCallback(type, value) {
    if (type == "insert_to_editor") {
        value = value.replace(/&lt;/gi, "<");
        value = value.replace(/&gt;/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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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(/&#39/g, '&apos').replace(/&amp;/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, "&lt;");
    html = html.replace(/>/gi, "&gt;");
    return html;
}

function loadCallback(type, value) {
    if (type == "insert_to_editor") {
        value = value.replace(/&lt;/gi, "<");
        value = value.replace(/&gt;/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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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(/&#39/g, '&apos').replace(/&amp;/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, "&lt;");
    html = html.replace(/>/gi, "&gt;");
    return html;
}

function loadCallback(type, value) {
    if (type == "insert_to_editor") {
        value = value.replace(/&lt;/gi, "<");
        value = value.replace(/&gt;/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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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(/&#39/g, '&apos').replace(/&amp;/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(/&#39/g, '&apos');});}
仅供参考:根据上述代码改编,参考:


对我有效:),希望有帮助。

我用这种方法解决了:

function saveCallback(element_id, html, body) {
    html = html.replace(/</gi, "&lt;");
    html = html.replace(/>/gi, "&gt;");
    return html;
}

function loadCallback(type, value) {
    if (type == "insert_to_editor") {
        value = value.replace(/&lt;/gi, "<");
        value = value.replace(/&gt;/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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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, "&lt;");
                html = html.replace(/>/gi, "&gt;");
                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(/&#39/g, '&apos').replace(/&amp;/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