不要在页面刷新时启动tinymce

时间:2013-07-02 18:22:13

标签: javascript jquery html jsp tinymce

我目前正在使用tinyMCE并使用oninit函数向messageBody添加自定义页脚。我在编辑器中获取页脚没有问题但是当用户添加导致页面刷新的附件时遇到问题。除页脚之外的所有内容都将从编辑器中删除。 (代码正在做它想要做的事情!)有没有办法让页面刷新时没有重新启动tinyMCE或者我可以采用不同的路径?代码如下:

    <script type="text/javascript">
    <!-- Intiate tinyMCE -->
    tinyMCE.init({

    // General options
    mode : "textareas",
    theme : "advanced",
    plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount",
    "apply_source_formatting" : true,
    "paste_auto_cleanup_on_paste" : false,
    "paste_retain_style_properties" : "all",
    //The below two lines to fix enter problem after a pastes is done by the user
    "force_br_newlines" : true,
    "force_p_newlines" : false,

    // Theme options
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,|,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "undo,redo,|,link,unlink,|,insertdate,inserttime,preview,|,forecolor,backcolor,|,tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,advhr,|,ltr,rtl,|,fullscreen,|,wordcount",

    //Calling a new CSS file to set Default Font and Text size
    content_css : "/js/tiny_mce/themes/advanced/skins/default/custom.css" + new Date().getTime(),
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,

    oninit: function(){
        tinyMCE.get('messageBody').setContent('<br><br><p>This message was generated by the Tool <br> If you are experiencing any issues with the Tool, please contact us <a href="mailto:someone@something.com">here</a> <br><a href="https://www.google.com">The Tool</a></p>');
    }



    });
    </script>

1 个答案:

答案 0 :(得分:1)

如果您让用户使用隐藏的iframe上传附件,那么您的主页与tinyMCE将无法刷新。您目前正在使用通用文件上传吗?如果你想改为使用打包的,我已经使用了一段时间的plupload,它是一个非常有用的文件上传工具。