javascript 参考错误:CKEDITOR 未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16417704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ReferenceError: CKEDITOR is not defined
提问by Slazer
I am trying to use the CKeditorbut the following error shows up (in JS console) when I try the samplefrom the tutorial and only a texbox shows in the browser.
我正在尝试使用CKeditor,但是当我尝试教程中的示例时(在 JS 控制台中)出现以下错误,并且浏览器中只显示一个 texbox。
ReferenceError: CKEDITOR is not defined [Break On This Error]
CKEDITOR.replace( 'editor1' ); /xampp/ (line 13)
ReferenceError: CKEDITOR 未定义 [Break On This Error]
CKEDITOR.replace('editor1'); /xampp/(第 13 行)
Note that the sample works when I try it on my webhosting. The file ckeditor.js is accessible from the browser.
请注意,当我在我的 webhosting上尝试时,该示例有效。文件 ckeditor.js 可从浏览器访问。
回答by kapa
Remove the leading slash from /ckeditor/ckeditor.js
(so try with ckeditor/ckeditor.js
).
删除前导斜杠/ckeditor/ckeditor.js
(因此尝试使用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.
因此,如果您使用像这样的 URL http://bp.php5.cz/
,然后说/ckeditor/ckeditor.js
,这将意味着http://bp.php5.cz/ckeditor/ckeditor.js
. 但是如果您的 URL 是localhost/xampp/
,它将解析为localhost/ckeditor/ckeditor.js
,这不是您想要的。
If you omit the leading slash, the relative URL will be resolved from the "current URL", so it will be correct in both cases.
如果省略前导斜杠,则相对 URL 将从“当前 URL”解析,因此在两种情况下都是正确的。
The safest way would be of course to use the absolute URL.
最安全的方法当然是使用绝对 URL。
回答by Ben
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.
就我而言,我在结束正文标签之前加载了 CDN 脚本,在CKEDITOR.replace( 'editor1' )
. 把它扔在头上,一切都很好。
回答by Dek Dekku
If you're loading from a CDN, check that you're using the full URL, including the "http:" part.
如果您从 CDN 加载,请检查您是否使用了完整的 URL,包括“http:”部分。