优秀的软件开发团队:深圳升蓝软件 数据库开发 .Net技术  |  ASP技术 PHP技术 JSP技术 应用技术类     
热门推荐
升蓝OA办公自动化系统
基于.Net技术的网络
协同办公环境
 
ASP基础
数据库相关
安全加密
全文检索
ASP应用
打印相关
客户端相关
XML相关
系统相关
正则表达式
ASP技巧
组件开发
脚本编码
FSO专题
邮件相关
远程脚本
性能优化
 
相关链接
深圳升蓝软件:系统集成、办公自动化平台、电子商务、电子政务、Web数据库、企业网站、游戏、手机应用程序、CDMA软件、电子出版物等,为客户提供优秀的解决方案
 
升蓝(www.hi-blue.com)为企业管理、政府办公提供成熟的、易于实施的IT技术服务,我们的解决方案包括OA办公自动化系统CRM客户关系管理系统ERP企业生产管理和订单管理系统电子政务系统、知识管理系统、企业门户、商业智能、工程项目管理等等...
 
电子政务解决方案
塑料/橡胶管理系统
知识管理系统简介
多媒体光盘方案
ERP企业资源管理
订单计划管理系统
PM工程项目管理系统
会员管理系统
相关资料下载
OA办公自动化系统
CRM客户关系管理系统
在线试用版本说明
OA 系统的用户手册
 
 
 
 
升蓝开发团队 > 技术资料 > ASP技术 > 打印相关 : 自己动手,结合javascript和dhtml做一个ubb编辑器(附?/td>

自己动手,结合javascript和dhtml做一个ubb编辑器(附?/H1>
March 25,2004

    看到chinaASP论坛的abc code editor了吗?是不是觉得很cool? 说真的,刚见到我还以为是用别的什么语言做的控件呢,后来才发现没有那么神秘的。前几天做一个商品bbs,客户要求支持ubb,同时也要做一个编辑器。现在我把做ubb的思路给大家讲一下。
    首先遇到的是界面问题,实际上这个很好解决,只是利用td的onmouseover、onmouseout和onmousedown来实现,具体实现方法件下面的代码。
    其次就是实现文本效果的问题,这个可以利用textRange的execCommand方法来实现。

   下面我给出一个简单的例子,你可以把它存为一个html文件,直接可以运行,这个例子的功能很简单,就是把编辑框中选定的文字变为粗体或斜体。其他功能你可以参照这个例子自己加上。
对了,先把这两个图片存下来。



file : ubb.html

<HTML>
<HEAD>

<TITLE>ubb演示</TITLE>
</HEAD>
<BODY>
<br><br>
<table width=300 cellspacing=2 cellpadding=2 border=0  bgcolor=lightgrey>
   <tr>
       <td id=tdBold  onclick=doAction("Bold") onmousedown="DoDown(tdBold );" onmouseover = "On_Mouseover(tdBold) ;" onmouseout="On_Mouseout(tdBold);">
          <img src='bold.gif' width=16 height=16  >
       </td>
       <td id=tdItalic onclick=doAction("Italic") onmousedown="DoDown(tdItalic);" onmouseover = "On_Mouseover(tdItalic) ;" onmouseout="On_Mouseout(tdItalic);">
          <img src='italic.gif' width=16 height=16 >
       </td>
       <td width=268>&nbsp;</td>
   </tr>
   <tr>
       <td colspan=3>
         <iframe id=Editor name=Editor border=0 scroll=no width=300 height=200>
         </iframe>
       </td>
   </tr>
</table>           

</BODY>
</HTML>

<script language=javascript>
  
  //initialize the iframe
  Editor.document .designMode = "On" ;
  Editor.document .open ;
  Editor.document .write ("&nbsp;") ;
  Editor.document .close ;
  Editor.focus ();
  
  function On_Mouseover(thisTD)
    {
      thisTD.style .borderLeft = "1px solid buttonhighlight" ;
      thisTD.style .borderRight = "1px solid buttonshadow";
      thisTD.style .borderTop = "1px solid buttonhighlight";
      thisTD.style .borderBottom = "1px solid buttonshadow";
    }

  function On_Mouseout(thisTD)
    {
      thisTD.style .borderLeft = "" ;
      thisTD.style .borderRight = "";
      thisTD.style .borderTop = "";
      thisTD.style .borderBottom = "";
    }
   
  function DoDown(thisTD)
    {
        thisTD.style .borderLeft   = "1px solid buttonshadow";
        thisTD.style .borderRight  = "1px solid buttonhighlight";
        thisTD.style .borderTop    = "1px solid buttonshadow";
        thisTD.style .borderBottom = "1px solid buttonhighlight";
        thisTD.style .paddingTop    = "2px";
        thisTD.style .paddingLeft   = "2px";
        thisTD.style .paddingBottom = "0px";
        thisTD.style .paddingRight  = "0px";   


    }  
   
  function doAction(str)
    {
      var m_objTextRange = Editor.document .selection.createRange();
      m_objTextRange.execCommand(str) ;
    }   
   

</script>      
数据库开发 | .Net技术 | ASP技术 | PHP技术 | JSP技术 | 应用技术类 | 升蓝开发小组
Copyright ? 2001-2004 Shenzhen Hi-blue Software Team 升蓝开发小组 All rights reserved