2
我對javasrcipt幾乎一無所知,但我確實知道我應該可以做到這一點。如何從外部JavaScript文件調用tiny_mce.init
我有幾個不同的tinymce.init調用,我想做。如果我將它們加載到頁面的頭部,它們可以正常工作,但如果將它們移動到外部.js文件中,則不會。有人能告訴我什麼是錯誤的以下?
我的頁面文件標題:
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript" src="../Scripts/tiny_mce/tiny_mce_src.js"></script>
<script type="text/javascript" src="../Scripts/load_tinymce.js"></script>
</head>
我的外部文件(load_tinymce.js):
tinyMCE.init({
mode: "specific_textareas",
editor_selector: "StandardEditBox",
theme: "advanced",
theme_advanced_buttons1: "bold,italic,underline,|,sub,sup,charmap",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "none",
forced_root_block: false,
height: "50",
encode: "xml",
theme_advanced_resizing: false,
setup: function (ed) {
ed.onSaveContent.add(function (i, o) {
o.content = o.content.replace(/'/g, "&apos");
});
}
});
tinyMCE.init({
mode: "specific_textareas",
editor_selector: "CommentsTextBox",
theme: "advanced",
theme_advanced_buttons1: "bold,italic,underline,|,sub,sup,charmap",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "none",
forced_root_block: false,
height: "150",
width: "580",
encode: "xml",
theme_advanced_resizing: false,
setup: function (ed) {
ed.onSaveContent.add(function (i, o) {"&apos");
});
}
});
我覺得應該有別的東西在我的js文件,但我不不知道它會是什麼。
謝謝,但腳本文件夾是從頁面所在的位置返回的一個文件夾。可以肯定的是,無論如何我都試過了,但這並沒有解決問題。 –
您是否驗證過它實際上正在加載?你可以在你的'.init'之前加入'alert(「Loaded」);'在其中一個文件中 - 如果在加載頁面時沒有顯示,那麼你的'src'不正確。 – Darren
再次感謝Darren。這很奇怪。我添加了警報。它從未顯示過。但是,我知道文件正確路徑,因爲當我查看頁面源時,FireFox將