ckeditor学习笔记1

ckeditor 介绍

ckeditor宣称是最好的web文本编辑器:

1.它功能强大,配置简单。

2.它是基于插件配置的,也就是说,你可以根据自己项目要求剔除掉一些特性。

目前,它最新版本是4.2.下面是一些有用的链接:

官网:http://ckeditor.com/

文档:http://docs.ckeditor.com/


示例

在看见最终效果请,需要安装ckeditor,安装是很简单的:

以java项目为例,可以将你下载的文件解压到webRoot根目录下,ckeditor是缺省目录。

本文打算用两个简单的例子,介绍它的用法。

使用默认配置

框架式编辑是使用CKeditor最常用的的方式,它通常的表现方式是在页面中指定位置放置工具栏和编辑区。

代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
		<link rel="stylesheet" href="ckeditor/samples/contents.css"
			type="text/css"></link>

	</head>

	<body>
		<textarea name="myEditor"></textarea>
		<script>
    	window.οnlοad=function(){
    		CKEDITOR.replace('myEditor');
    	}
    </script>
	</body>
</html>

效果如下:


使用你喜欢的配置

很多时候,不同的项目需要我们的编辑器有不同的toolbar,我们可以修改config.js文件,加入以下代码:

config.toolbar =[['Source','Styles', 'Format','FontSize','Font'],  
                     ['TextColor', '-' ,'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link','Unlink','-','Cut','Copy','Paste','-','Image','Flash','Smiley','Maximize']  
                ];
效果如下:





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值