fckeditor没有显示textarea

时间:2013-07-13 10:40:02

标签: hidden fckeditor

我正在为我的项目执行管理面板,但使用textarea编辑的FCKEDITOR未显示。

我得到以下来源:

<input type="hidden" id="text" name="text" value="here shows the text itself....." style="display:none" />
<input type="hidden" id="text___Config" value="" style="display:none" />
<iframe id="text___Frame" src="fckeditor/editor/fckeditor.html?InstanceName=text&amp;Toolbar=Default" width="890" height="600" frameborder="0" scrolling="no">
</iframe><br>

1 个答案:

答案 0 :(得分:0)

整合FCKEditor

第1步
首先要做的是在页面中包含“JavaScript Integration Module”脚本,如下所示:

<script type="text/javascript" src="fckeditor/fckeditor.js"></script>

第2步
现在FCKeditor类已经可以使用了。在页面中有三种方法可以创建FCKeditor:

方法1
内联方法(首选):转到页面正文,转到您希望编辑器所在的位置(通常在表单中)并将以下脚本放在那里:

<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.Create();
</script>

方法2
TEXTAREA替换方法:

添加“onload”方法:

<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>

添加以下代码以替换页面中的现有TEXTAREA:

<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>

方法3
CreateHtml()方法(适用于AJAX):对于AJAX应用程序,您将动态设置内部html;例如:

var div = document.getElementById("myFCKeditor");
var fck = new FCKeditor("myFCKeditor");
div.innerHTML = fck.CreateHtml();

示例代码
示例代码1

<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</head>
<body>
<form>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.Create();
</script>
</form>
</body>
</html>

示例代码2

<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
</head>
<body>
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
</body>
</html>

Source site