gpt4 book ai didi

jquery - 我可以简化 javascript 函数的调用方式吗?

转载 作者:行者123 更新时间:2023-12-01 04:22:40 24 4
gpt4 key购买 nike

我在多个屏幕上内联执行以下内容:

tinyMCE.init({
// General options
mode : "specific_textareas",
editor_selector : "mceEditor",
theme: "advanced",
plugins: "autolink,lists,spellchecker,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",

// Theme options
theme_advanced_buttons1: "save,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",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,

// Skin options
skin: "o2k7",
skin_variant: "silver",

// Example content CSS (should be your site CSS)
content_css: "css/example.css",

// Drop lists for link/image/media/template dialogs
template_external_list_url: "js/template_list.js",
external_link_list_url: "js/link_list.js",
external_image_list_url: "js/image_list.js",
media_external_list_url: "js/media_list.js",

// Replace values for the template plugin
template_replace_values: {
username: "Some User",
staffid: "991234"
}
});

我想将其移至文件中然后调用它。有没有一种简单的方法可以做到这一点?

最佳答案

类似于Xander的答案,但我只会全局存储选项对象。

window.tinyMCEOptions = {
// General options
mode : "specific_textareas",
/* Your other options here.
* Store in your favorite .js file and link your page to it.
*/
}

然后调用tinyMCE.init,如下所示:

tinyMCE.init(window.tinyMCEOptions);

这样做的好处是它可以让您轻松更改选项:

window.tinyMCEOptions.content_css: 'css/different.css'
tinyMCE.init(window.tinyMCEOptions);

关于jquery - 我可以简化 javascript 函数的调用方式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9178617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com