1. 程式人生 > >ckeditor中 config.js等通過ckeditor.js引入檔案手動修改方法

ckeditor中 config.js等通過ckeditor.js引入檔案手動修改方法

因為除了ckeditor.js之外的引用檔案是通過ckeditor.js自動新增<script>或<link>標籤實現檔案的引入,引入的根目錄是展示頁面的地址。有時需要手動修改通過ckeditor.js引入的檔案。這是需要在引入ckeditor.js之前定義window.CKEDITOR_BASEPATH = '../../static'(目錄自己修改),編輯器將強制修改引用地址。

ckeditor.js的這一部分原始碼是處理定義地址的:

basePath: function() {
var b = window.CKEDITOR_BASEPATH || "";
if (!b)
for (var c = document.getElementsByTagName("script"), d = 0; d < c.length; d++) {
var h = c[d].src.match(a);
if (h) {
b = h[1];
break
}
} - 1 == b.indexOf(":/") && "//" != b.slice(0, 2) && (b = 0 === b.indexOf("/") ? location.href.match(/^.*?:\/\/[^\/]*/)[0] +
b : location.href.match(/^[^\?]*\/(?:)/)[0] + b);
if (!b) throw 'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.';
return b
}(),