前提:
1 已经复制了fckediotr
2 已经引入了jar包
1 第一个错误
当测试的时候fckeditor不会显示
<%@ page language="java" pageEncoding="UTF-8"%>
<html>
<head>
<title>录入日志</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.οnlοad=function()
{
var oFCKeditor=new FCKeditor('myTestArea');
oFCKeditor.BasePath="/zzx/fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
</head>
<body>
<textarea style="width:750px; height:300px" name="myTestArea"></textarea>
<!--
<form name="form" action="add.action" method="post">
标题:<br>
<input type="text" name="title" style="width:750px" /><p/>
内容:<br>
<textarea style="width:750px; height:300px" name="myTestArea" ></textarea>
</form>
<input type="button" οnclick="submit()" value="发布"/>
<script type="text/javascript">
function submit()
{
form.submit();
}
</script>
-->
</body>
</html>
仔细检查以后发现没有引入新版的w3c标准
应该文件如下
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>录入日志</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.οnlοad=function()
{
var oFCKeditor=new FCKeditor('myTestArea');
oFCKeditor.BasePath="/zzx/fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
</head>
<body>
<textarea style="width:750px; height:300px" name="myTestArea"></textarea>
<!--
<form name="form" action="add.action" method="post">
标题:<br>
<input type="text" name="title" style="width:750px" /><p/>
内容:<br>
<textarea style="width:750px; height:300px" name="myTestArea" ></textarea>
</form>
<input type="button" οnclick="submit()" value="发布"/>
<script type="text/javascript">
function submit()
{
form.submit();
}
</script>
-->
</body>
</html>
2
当jsp文件在根目录下的时候没有问题,但是当他放置到jsp目录下的时候出现问题,不会显示
仔细观察下发现,js文件没有引入,因为原来的js文件使用的当前目录下的路径。我们应该通过网站的根路径访问它。
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>录入日志</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="/zzx/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.οnlοad=function()
{
var oFCKeditor=new FCKeditor('myTestArea');
oFCKeditor.BasePath="/zzx/fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
</head>
<body>
<form name="form" action="add.action" method="post">
标题:<br>
<input type="text" name="title" style="width:750px" /><p/>
内容:<br>
<textarea style="width:750px; height:300px" name="myTestArea" ></textarea>
</form>
<input type="button" οnclick="submit()" value="发布"/>
<script type="text/javascript">
function submit()
{
form.submit();
}
</script>
</body>
</html>