问题
I am trying to use the CKeditor but the following error shows up (in JS console) when I try the sample from the tutorial and only a texbox shows in the browser.
ReferenceError: CKEDITOR is not defined [Break On This Error]
CKEDITOR.replace( 'editor1' ); /xampp/ (line 13)
Note that the sample works when I try it on my webhosting. The file ckeditor.js is accessible from the browser.
回答1:
Remove the leading slash from /ckeditor/ckeditor.js
(so try with ckeditor/ckeditor.js
).
The leading slash means the "root".
So if you are using an URL like http://bp.php5.cz/
, and then say /ckeditor/ckeditor.js
, it will mean http://bp.php5.cz/ckeditor/ckeditor.js
. But if your URL is localhost/xampp/
, it will resolve to localhost/ckeditor/ckeditor.js
, which is not what you want.
If you omit the leading slash, the relative URL will be resolved from the "current URL", so it will be correct in both cases.
The safest way would be of course to use the absolute URL.
回答2:
In my case, I loaded the CDN script before my closing body tag, after CKEDITOR.replace( 'editor1' )
. Tossed it in the head and it's all good.
回答3:
If you're loading from a CDN, check that you're using the full URL, including the "http:" part.
来源:https://stackoverflow.com/questions/16417704/referenceerror-ckeditor-is-not-defined