UBB编辑器
程序员文章站
2022-05-18 12:58:51
<!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>
<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>