我们在做bbs项目的时候就需要用到ubb编辑器,后台管理人员一般使用的是CKEditor编辑器,网友们用的一般是ubb编辑器,很多人对ubb编辑器都不是非常的了解,下面就是中国E盟小编为大家浅析UBB编辑器。
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""' target=_blank rel=nofollow>http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>UBB编辑器</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<linkhref="style.css"rel="stylesheet"type="text/css">
<scriptlanguage="JavaScript">
<!--
if(navigator.appName=="MicrosoftInternetExplorer")
{
isIE=true;
}
else
{
isIE=false;
}
functionAddText(NewCode)
{
if(document.all){
insertAtCaret(document.ubbform.Content,NewCode);
document.ubbform.Content.focus();
}
else
{
document.ubbform.Content.value+=NewCode;
document.ubbform.Content.focus();
}
}
functioninsertAtCaret(textEl,text){
if(textEl.createTextRange&&textEl.caretPos)
{
varcaretPos=textEl.caretPos;
caretPos.text+=caretPos.text.charAt(caretPos.text.length-2)==''?text+'':text;
}
elseif(textEl)
{
textEl.value+=text;
}
else
{
textEl.value=text;
}
}
functionubbFormat(what)
{
if(document.selection&&document.selection.type=="Text")
{
varrange=document.selection.createRange();
range.text="["+what+"]"+range.text+"[/"+what+"]";
}
else
{
txt=window.prompt("请输入内容","");
if(txt!=null){
AddTxt="["+what+"]"+txt;
AddText(AddTxt);
AddText("[/"+what+"]");
}
}
}
functionubbInsert(what)
{
if(document.selection&&document.selection.type=="Text")
{
varrange=document.selection.createRange();
range.text="["+what+"]"+range.text+"[/"+what+"]";
}
else
{
txt=window.prompt("请输入内容","");
if(txt!=null){
AddTxt="["+what+"]"+txt;
AddText(AddTxt);
AddText("[/"+what+"]");
}
}
}
functionchsize(size){
if(document.selection&&document.selection.type=="Text")
{
varrange=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]");
}
}
}
functionchfont(font){
if(document.selection&&document.selection.type=="Text"){
varrange=document.selection.createRange();
range.text=""+range.text+"";
}
else
{
txt=window.prompt("请输入内容","");
if(txt!=null)
{
AddTxt=""+txt;
AddText(AddTxt);
AddText("");
}
}
}
functionchcolor(color){
if(document.selection&&document.selection.type=="Text"){
varrange=document.selection.createRange();
range.text=""+range.text+"";
}
else
{
txt=window.prompt("请输入内容","");
if(txt!=null){
AddTxt=""+txt;
AddText(AddTxt);
AddText("");
}
}
}
//-->
</script>
</head>
<body>
<formmethod=postname="ubbform"action="">
<tablealign="center"border="0">
<tr>
<td>
<selectname="font"onFocus="this.selectedIndex=0"onChange="chfont(this.options[this.selectedIndex].value)"size="1">
<optionvalue=""selected>选择字体</option>
<optionvalue="宋体">宋体</option>
<optionvalue="黑体">黑体</option>
<optionvalue="Arial">Arial</option>
<optionvalue="BookAntiqua">BookAntiqua</option>
<optionvalue="CenturyGothic">CenturyGothic</option>
<optionvalue="CourierNew">CourierNew</option>
<optionvalue="Georgia">Georgia</option>
<optionvalue="Impact">Impact</option>
<optionvalue="Tahoma">Tahoma</option>
<optionvalue="TimesNewRoman">TimesNewRoman</option>
<optionvalue="Verdana">Verdana</option>
</select>
<selectname="size"onFocus="this.selectedIndex=0"onChange="chsize(this.options[this.selectedIndex].value)"size="1">
<optionvalue=""selected>字体大小</option>
<optionvalue="-2">-2</option>
<optionvalue="-1">-1</option>
<optionvalue="1">1</option>
<optionvalue="2">2</option>
<optionvalue="3">3</option>
<optionvalue="4">4</option>
<optionvalue="5">5</option>
<optionvalue="6">6</option>
<optionvalue="7">7</option>
</select>
<selectname="color"onFocus="this.selectedIndex=0"onChange="chcolor(this.options[this.selectedIndex].value)"size="1">
<optionvalue=""selected>字体颜色</option>
<optionvalue="Black"style="background-color:black;color:black;">Black</option>
<optionvalue="White"style="background-color:white;color:white;">White</option>
<optionvalue="Red"style="background-color:red;color:red;">Red</option>
<optionvalue="Yellow"style="background-color:yellow;color:yellow;">Yellow</option>
<optionvalue="Pink"style="background-color:pink;color:pink;">Pink</option>
<optionvalue="Green"style="background-color:green;color:green;">Green</option>
<optionvalue="Orange"style="background-color:orange;color:orange;">Orange</option>
<optionvalue="Purple"style="background-color:purple;color:purple;">Purple</option>
<optionvalue="Blue"style="background-color:blue;color:blue;">Blue</option>
<optionvalue="Beige"style="background-color:beige;color:beige;">Beige</option>
<optionvalue="Brown"style="background-color:brown;color:brown;">Brown</option>
<optionvalue="Teal"style="background-color:teal;color:teal;">Teal</option>
<optionvalue="Navy"style="background-color:navy;color:navy;">Navy</option>
<optionvalue="Maroon"style="background-color:maroon;color:maroon;">Maroon</option>
<optionvalue="LimeGreen"style="background-color:limegreen;color:limegreen;">LimeGreen</option>
</select>
</td>
</tr>
<tr>
<td>
<imgsrc="ubb/bold.gif"border="0"alt="粗体"onClick="ubbFormat('B')"><imgsrc="ubb/italicize.gif"border="0"alt="斜体"onClick="ubbFormat('I')"><imgsrc="ubb/underline.gif"border="0"alt="下划线"onClick="ubbFormat('U')"><imgsrc="ubb/center.gif"border="0"alt="居中对齐"onClick="ubbFormat('CENTER')"><imgsrc="ubb/email.gif"border="0"alt="插入EMAIL地址"onClick="ubbFormat('EMAIL')"><imgsrc="ubb/url.gif"border="0"alt="插入网址"onClick="ubbFormat('URL')"><imgsrc="ubb/quote.gif"border="0"alt="引用内容"onClick="ubbFormat('QUOTE')"><imgsrc="ubb/wmv.gif"border="0"alt="插入视频"onClick="ubbFormat('MEDIA')"><imgsrc="ubb/flash.gif"border="0"alt="插入flash动画"onClick="ubbInsert('FLASH')"><imgsrc="ubb/image.gif"border="0"alt="插入图片"onClick="ubbInsert('IMG')">
</td>
</tr>
<tr>
<td><textareaname="Content"rows="10"cols="80"></textarea></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
</body>
</html>
以上就是浅析UBB编辑器的内容,希望对大家的学习有所帮助,也希望大家多多支持中国E盟技术频道。





