网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.处理二进制数据.
.asp实现在web中显示电子表格数据.
.LINE 的计数器源程序(附源代码).
.网页加速之图形处理篇.
.ASP中Cookie使用指南.
.Server.Execute和#include相异之.
.aspjpeg组件高级使用方法介绍.
.方便购买的电子商务站点设计技巧.
.一种效率极高的分类算法 .
.使用命名管道访问SQL Server.
.ASP的Internet/Intranet编程常见.
.让你的网站首页自动选择语言.
.ASP提速技巧.
.关于0x80040e14错误 .
.ASP提速技巧五则.
.关于在浏览器中执行*.exe文件的深.
.XML技术上传文件.
.使用ASP与JAVASCRIPT配合实现多个.
.用ASP编写计数器的优化方法.
.如何使用 Microsoft Access 和 A.

自己动手,结合javascript和dhtml做一个ubb编辑器

发表日期:2000-8-6


看到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>      

上一篇:使用ADO批量更新记录(源代码) 人气:14012
下一篇:检查Email地址的比较完善的正则表达式函数 人气:18400
浏览全部ubb编辑器的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐