javascript - 不要在页面刷新时启动tinymce

标签 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>

最佳答案

让用户使用隐藏的 iframe 上传附件怎么样,因为这样您的 tinyMCE 主页将不会刷新。您当前使用的是通用文件上传吗?如果您想更改为使用打包的,我已经使用 plupload 一段时间了,它是一个非常有用的文件上传实用程序。

关于javascript - 不要在页面刷新时启动tinymce,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17433013/

相关文章:

javascript - 表排序后函数停止工作

javascript - 如何在一个更大的函数下的 for 循环或 if 语句中压缩和调用每个函数?

html - 我的超链接遍及整个页面,而不仅仅是图像

c# - 隐藏我的网站是用 ASP.NET 构建的事实

javascript - 强制 "Tab"点击在元素内移动 - Jquery/Javascript

android - CSS - 布局一团糟

javascript - "Splitting"长字

javascript - HTML5 Canvas 必须是矩形吗?

javascript - ES6中有没有一种简单的方法来减少迭代器?

javascript - Angular http 服务循环