我想将fckeditor与我的表单集成我从http://ckeditor.com/download下载ckeditor库
一切正常,但是它给出了以下错误
的ReferenceError:
ReferenceError:未定义CKeditor
以下是js代码
<script src="<?php echo $this->baseUrl(); ?>/js/fckeditor/fckeditor.js" type="text/javascript"></script>
<script type="text/javascript">
function setUpFCK() {
if (document.getElementById('body')) {
var oFCKeditor = new CKeditor('body');
oFCKeditor.BasePath = "http://localhost/ZendTecAdmin/js/fckeditor/";
oFCKeditor.Height = 400;
oFCKeditor.ReplaceTextarea();
}
}
</script>
</head>
<body onload="setUpFCK()">
答案 0 :(得分:0)
1-尝试检查JS文件是否在&#34; public / js&#34;并且可以访问它,在这种情况下:
本地主机/ JS / fckeditor的/ fckeditor.js
2-您可以使用ZF2视图助手附加脚本文件
<?php echo $this->headScript()
// you can also use appendFile if the library has dependencies, that needed to be loaded first.
->prependFile($this->basePath() . '/js/fckeditor/fckeditor.js');
?>
更新
1-添加新脚本标记以将onload事件处理程序附加到window
而不是body
,并删除onload属性。
<script>
window.onload = function () {
setUpFCK();
}
</script>
2-或使用onload函数附加onload事件处理程序,例如。
<script>
function attachEvent(){
window.onload = setUpFCK;
}
</script>
<body onload="attachEvent()">