2

我目前正在尝试弄清楚如何将外部脚本加载到 tinymce 中。该脚本是 p7EHCscript,用于根据较大 div 的高度使两个 div 等高。

我需要 p7EHC 脚本能够在 tinymce 编辑器中执行此操作,因此它看起来就像正在创建的最终页面。

我目前使用 tinymce 的设置是:

tinyMCE.init({

            // General options
            mode : "textareas",
            editor_selector : "mceEditor",
            editor_deselector : "mceNoEditor",
            remove_script_host : false,
            convert_urls : false,
            content_css : 'http://localhost/tmtphotography/css/mce.css',

            width: "1030",
            height : "480",

            theme : "advanced",
            plugins : "safari, 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,preview",
            file_browser_callback : "filebrowser",
            // Theme options
            theme_advanced_buttons1 : "save,preview,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage,imgae,media,link",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,

             theme_advanced_font_sizes : "10px,12px,13px,14px,16px,24px",
     font_size_style_values : "xx-small,x-small,12pt,medium,large,x-large,xx-large",


            // Skin options
            skin : "o2k7",
            // Example content CSS (should be your site CSS)


    });
  `

任何有助于理解如何进行此操作的帮助将不胜感激。

4

1 回答 1

2

我假设您想将 scipt 作为脚本标签添加到文档头:

  <script type="text/javascript" src="javascript/p7EHCscripts.js"></script>

由于tinymce 使用自己的iframe 和自己的文档,我们需要处理这个iframe。这是必要的代码

var iframe_id = 'your_editor_id' + '_ifr'; // place your editor id here+'_ifr'
with(document.getElementById(iframe_id).contentWindow) {

  var h = document.getElementsByTagName("head");
  if (!h.length) return;
  var scripttag = document.createElement("script");
  scripttag.type = "text/javascript";
  scripttag.src = "http://myserver.com/my_dir1/my_dir2/javascript/p7EHCscripts.js"; // example
  h[0].appendChild ( scripttag );
}
于 2013-01-18T13:49:28.570 回答