UBB编辑器

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>UBB编辑器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
if(navigator.appName == "Microsoft Internet Explorer")
{
    isIE=true;
}
else
{
    isIE=false;
}


function AddText(NewCode) 
{
    if(document.all){
        insertAtCaret(document.ubbform.Content, NewCode);
        document.ubbform.Content.focus();
    }
    else
    {
        document.ubbform.Content.value += NewCode;
        document.ubbform.Content.focus();
    }
}

function insertAtCaret (textEl, text){
    if (textEl.createTextRange && textEl.caretPos)
    {
        var caretPos = textEl.caretPos;
        caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
    }
    else if(textEl)
    {
        textEl.value += text;
    }
    else
    {
        textEl.value = text;
    }
}

function ubbFormat(what) 
{
    if (document.selection && document.selection.type == "Text")
    {
        var range = document.selection.createRange();
        range.text = "["+what+"]" + range.text + "[/"+what+"]";
    }
    else
    {
        txt=window.prompt("请输入内容","");     
        if (txt!=null) {           
                AddTxt="["+what+"]"+txt;
                AddText(AddTxt);
                AddText("[/"+what+"]");
        }       
    } 
}

function ubbInsert(what) 
{
    if (document.selection && document.selection.type == "Text")
    {
        var range = document.selection.createRange();
        range.text = "["+what+"]" + range.text + "[/"+what+"]";
    }
    else
    {
        txt=window.prompt("请输入内容","");     
        if (txt!=null) {           
                AddTxt="["+what+"]"+txt;
                AddText(AddTxt);
                AddText("[/"+what+"]");
        }       
    } 
}

function chsize(size) {
    if (document.selection && document.selection.type == "Text")
    {
        var range = document.selection.createRange();
        range.text = "[size=" + size + "]" + range.text + "[/size]";
    }
    else
    {                       
        txt=window.prompt("请输入内容",""); 
        if (txt!=null)
        {             
            AddTxt="[size="+size+"]"+txt;
            AddText(AddTxt);
            AddText("[/size]");
        }        
    }
}

function chfont(font) {
    if (document.selection && document.selection.type == "Text") {
    var range = document.selection.createRange();
    range.text = " " + range.text + "";
    }
    else
    {                  
        txt=window.prompt("请输入内容","");
        if (txt!=null)
        {             
            AddTxt=" "+txt;
            AddText(AddTxt);
            AddText("
");
        }        
    }  
}

function chcolor(color) {
    if (document.selection && document.selection.type == "Text") {
    var range = document.selection.createRange();
    range.text = " " + range.text + "";
    }
    else
    {  
    txt=window.prompt("请输入内容","");
        if(txt!=null) {
            AddTxt=" "+txt;
            AddText(AddTxt);
            AddText("
");
        }
    }
}

//-->
</script>
</head>
<body>
<form method=post name="ubbform" action="">
<table align="center" border="0">
<tr>
    <td>
    <select name="font" onFocus="this.selectedIndex=0" onChange="chfont(this.options[this.selectedIndex].value)" size="1">
        <option value="" selected>选择字体</option>
        <option value="宋体">宋体</option>
        <option value="黑体">黑体</option>
        <option value="Arial">Arial</option>
        <option value="Book Antiqua">Book Antiqua</option>
        <option value="Century Gothic">Century Gothic</option>
        <option value="Courier New">Courier New</option>
        <option value="Georgia">Georgia</option>
        <option value="Impact">Impact</option>
        <option value="Tahoma">Tahoma</option>
        <option value="Times New Roman">Times New Roman</option>
        <option value="Verdana">Verdana</option>
    </select>
    <select name="size" onFocus="this.selectedIndex=0" onChange="chsize(this.options[this.selectedIndex].value)" size="1">
          <option value="" selected>字体大小</option>
          <option value="-2">-2</option>
          <option value="-1">-1</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
    </select>
    <select name="color"  onFocus="this.selectedIndex=0" onChange="chcolor(this.options[this.selectedIndex].value)" size="1">
          <option value="" selected>字体颜色</option>
          <option value="Black" style="background-color:black;color:black;">Black</option>
          <option value="White" style="background-color:white;color:white;">White</option>
          <option value="Red" style="background-color:red;color:red;">Red</option>
          <option value="Yellow" style="background-color:yellow;color:yellow;">Yellow</option>
          <option value="Pink" style="background-color:pink;color:pink;">Pink</option>
          <option value="Green" style="background-color:green;color:green;">Green</option>
          <option value="Orange" style="background-color:orange;color:orange;">Orange</option>
          <option value="Purple" style="background-color:purple;color:purple;">Purple</option>
          <option value="Blue" style="background-color:blue;color:blue;">Blue</option>
          <option value="Beige" style="background-color:beige;color:beige;">Beige</option>
          <option value="Brown" style="background-color:brown;color:brown;">Brown</option>
          <option value="Teal" style="background-color:teal;color:teal;">Teal</option>
          <option value="Navy" style="background-color:navy;color:navy;">Navy</option>
          <option value="Maroon" style="background-color:maroon;color:maroon;">Maroon</option>
          <option value="LimeGreen" style="background-color:limegreen;color:limegreen;">LimeGreen</option>
    </select>
    </td>
</tr>
<tr>
    <td>
    <img src="ubb/bold.gif" border="0" alt="粗体" onClick="ubbFormat('B')"><img src="ubb/italicize.gif" border="0" alt="斜体" onClick="ubbFormat('I')"><img src="ubb/underline.gif" border="0" alt="下划线" onClick="ubbFormat('U')"><img src="ubb/center.gif" border="0" alt="居中对齐" onClick="ubbFormat('CENTER')"><img src="ubb/email.gif" border="0" alt="插入EMAIL地址" onClick="ubbFormat('EMAIL')"><img src="ubb/url.gif" border="0" alt="插入网址" onClick="ubbFormat('URL')"><img src="ubb/quote.gif" border="0" alt="引用内容" onClick="ubbFormat('QUOTE')"><img src="ubb/wmv.gif" border="0" alt="插入视频" onClick="ubbFormat('MEDIA')"><img src="ubb/flash.gif" border="0" alt="插入flash动画" onClick="ubbInsert('FLASH')"><img src="ubb/image.gif" border="0" alt="插入图片" onClick="ubbInsert('IMG')">
    </td>
</tr>
<tr>
    <td><textarea name="Content" rows="10" cols="80"></textarea></td>
</tr>
<tr>
    <td></td>
</tr>
</table>
</form>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编辑器是根据discuz论坛(php 7.0)版UBB编辑器进行二次开发的,默认为所见即所得模式。本来没有打算进行二次开发的,但由于项目是.net,在网上搜了一大箩筐UBB编辑器都不怎么样,还是觉得discuz这个比较好,但这个只找到了php版,或许你会说discuz不是有.net版吗,但我要告诉你的是,.net版的确是有,但是要单纯的把编辑器剥离出来,是非常麻烦的,因为他ubb.cs这个编辑器的类里关联了很多东西是你不想要的,改动太麻烦了。为此我就进行了二次开发,并把UBB编辑器里的表情库从通过JS手工定义改成了从smilies.xml动态读取,便于维护表情库。编器也做成了组件,你只需要在VS开发工具中添加引用UBBTextBox.dll这个组件,像拖放控件一样拖放即可,兼容IE6.0、7.0、8.0和Firefox浏览器,多次测试过。详情请见源码。<BR><BR> 注:请在IIS建立单独站点,因为此程序组件设置脚本文件的路径是“/”根路径形式,如果不设置站点是找不到脚本文件的,这个是做为一个WEB程序员最基本要了解的,有很多人用不起就是因为这个,还说我传的东西用不起,你们连基本的知识都不会,算WEB程序员吗? <br> 我讨厌CSDN资源不能更新,只能更新文字说明,这个UBB我后面又进行了一次升级,增加了图片上传接口、全屏编辑、会员未登录情况下提示会员登录禁用UBB、浏览器进一步兼容等,本想打包进行更新的,但更新不了,只能对下载的网友们说声抱歉了,如果你们需要最新的请联系我,如果不用最新的也可以用的。预览地址:http://www.xinglico.com/News/20110720/20110720_7065_1.htm

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值