集成 FCKEditor
第 1 步
首先要做的是在页面中包含“JavaScript 集成模块”脚本,就像这样:
<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>
源站点