其实网络上有好多很成功的文本编辑器,而且也有很多成功的网站,例如pen.io它的操作超简单--编辑+保存!而通过这些文本编辑器,让这些网站不必像博客服务那样为每个用户开辟一个后台管理系统,而实现前台修改! 附:aloha下载地址 那么为什么要说Aloha呢,因为它是基于HTML5,纯js的一个东西,而不像其他组件那样需要负责的引用API。 在中文的资料了我找了很久都没有说aloha怎么用,看了一些外文档案!大家想看Demo吧,这里有好多!我自己做了个例子,不过因为暂时登不上服务器就截个图吧:

在你的<head>加入下面的js文件,注意它的根文件命名为aloha哦!
<head> ... <script type="text/javascript" src="aloha/aloha/aloha.js"></script> <script type="text/javascript" src="aloha/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js"></script> <script type="text/javascript" src="aloha/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js"></script> <script type="text/javascript" src="aloha/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js"></script> </head>
之后在你想要编辑的地方,因为aloha是基于jquery的,所以你可以直接进行jquery编程!将所要进行编辑的文本块aloha化就可以了: 你可以直接用:
$(function(){ $('#content').aloha(); }); 其实它用处很大,假如我们的博客里面,其实可以利用session进行判断,假如是作者所有,那么就加载这些js文件,让作者可以在前台直接编辑!
假如你想进行实验,可以先用request方便点: 前台用个id为script的div来放置这些js代码,基于雅虎js性能优化第一准则,将div放置在body结束前最好了 <%=news1 %>//绑定你想要的东西 <div runat="server" id="script"></div>简单的js:$(function () { $("#edit").aloha(); }) 简单的request验证:
if (HttpContext.Current.Request["password"]!=null) password=HttpContext.Current.Request["password"].ToString(); // password=HttpContext.Current.Session["password"].ToString(); if(password=="123") script.InnerHtml="<script type='text/javascript' src='aloha/aloha/aloha.js'></script><script type='text/javascript' src='aloha/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js'></script><script type='text/javascript' src='aloha/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js'></script><script type='text/javascript' src='aloha/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js'></script>";