<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>可视html编辑器</title>
<style>
td,a,p,input,select {font-size:9pt;font-face:menu};
.up{
border-left: 1px solid rgb(233,244,249);
border-right: 1px solid rgb(12,12,12);
border-bottom: 1px solid rgb(12,12,12);
border-top: 1px solid rgb(233,244,249);
cursor:hand;
}
.down
{ border-right: 1px solid rgb(233,244,249);
border-left: 1px solid rgb(12,12,12);
border-top: 1px solid rgb(12,12,12);
border-bottom: 1px solid rgb(233,244,249);
cursor:hand;
}
.none{
border-top: 1px solid rgb(208,208,200);
border-left: 1px solid rgb(208,208,200);
border-bottom: 1px solid rgb(208,208,200);
border-right: 1px solid rgb(208,208,200);
cursor:hand;}
</style>
<script language="javascript">
var format = "normal"; //当前的模式:normal,html,preview
var inithtml = ""; //初始化的内容
var cssfile="";
var edit; //当前选择的文本编辑区域对象
var rangetype; //对象类别
var cssfile="";
var returnvalue="";
function setfocus() {
editor.focus();
}
function fixsize()
{
document.all.editor.style.height = math.max(document.body.clientheight -
document.all.editor.offsettop, 0);
}
function selectrange(){
edit = editor.document.selection.createrange();
rangetype = editor.document.selection.type;
}
function execcommand(command,para) {
if (format == "normal"){
setfocus();
selectrange();
if ((command == "undo") || (command == "redo"))
document.execcommand(command);
else
if (para=="")
edit.execcommand(command);
else
edit.execcommand(command, false, arguments[1]);
editor.focus();
if (rangetype != "control") edit.select();
}
}
function swapmodes(mode) {
switch(mode){
case "normal":
if (format == "html")
editor.document.body.innerhtml = editor.document.body.innertext;
else
{
inithtml = editor.document.body.innerhtml;
initeditor("on");
}
break;
case "html":
if (format == "preview"){
inithtml = editor.document.body.innerhtml;
initeditor("on");
}
editor.document.body.innertext = editor.document.body.innerhtml;
break;
default:
var strhtml = "";
if(format == "html")
inithtml = editor.document.body.innertext;
else
inithtml = editor.document.body.innerhtml;
initeditor("off");
break;
}
editor.focus();
format=mode;
}
function pastemark(mark) //paste有标志
{
var strhtml;
if (mark=='') return(0);
setfocus();
selectrange();
var t=mark.split(" ");
if (mark=="hr")
strhtml="<hr>"
else
strhtml = "<" + mark + ">" + edit.text + "</" + t[0] + ">";
if (format == "normal")
edit.pastehtml(strhtml);
else
edit.text=strhtml;
editor.focus();
edit.select();
}
function pastehtml(html) //直接paste内容
{
setfocus();
selectrange();
if (format == "normal")
edit.pastehtml(html);
else
edit.text=html;
editor.focus();
edit.select();
}
function initeditor(model) {
editor.document.designmode=model;
editor.document.open();
editor.document.write(inithtml);
editor.document.close();
inithtml = "";
if(cssfile!="")
editor.document.createstylesheet(cssfile);
editor.document.body.style.fontfamily = "";
editor.document.body.style.fontsize ="";
}
function check(t,n)
{
if(n==1) t.classname ="up"
else
if(n==2) t.classname ="down"
else t.classname ="none"
}
function insertattach()
{
alert("您选择了插入附件功能");
}
function insertimage()
{
alert("您选择了插入图片功能");
}
function checkos()
{
if((window.navigator.useragent.indexof("ie 5") < 1) &&
(window.navigator.useragent.indexof("ie 6") < 1)) {
alert("请使用microsoft internet explorer 5.0\n或更高版本的浏览器!");
window.close();
}
}
function selectformat(status) //编辑模式的更改
{
swapmodes(status);
switch(status) //需要更改的编辑模式
{ case "normal":
html.style.display="none";
preview.style.display="none";
normal.style.display="block";
break;
case "html":
normal.style.display="none";
preview.style.display="none";
html.style.display="block";
break;
default:
normal.style.display="none";
html.style.display="none";
preview.style.display="block";
break;
}
return(false);
}
function showhelp()
{
showmodaldialog("help.htm","","dialogwidth:350px;dialogheight:250px;status:no;");
}
function addtable()
{ if(format!="preview")
{ returnvalue=window.showmodaldialog("addtable.htm","",
"dialogwidth=310px;dialogheight=150px;status=0");
if(returnvalue && returnvalue!="") pastehtml(returnvalue);
}
}
function doformat(what,para,mark) {
if(format!="preview")
if (format=='normal')
execcommand(what,para);
else
pastemark(mark);
}
function doselectclick(str,el,mark) {
if(format!="preview")
{
var index = el.selectedindex;
if (index != 0)
{ el.selectedindex = 0;
if (format=='normal' && el.id != "otherformat")
doformat(str,el.options[index].value);
else
pastemark(mark);
}
}
}
function selectcolor(id)
{
var c=window.showmodaldialog("selectcolor.htm",id.style.backgroundcolor,
"dialogwidth=420px;dialogheight=340px;status=0");
if(c && c!="")
id.style.backgroundcolor=c;
}
</script>
</head>
<body scroll="no" bgcolor=d0d0c8 onload="initeditor('on');" leftmargin=5 topmargin=5>
<table width="100%" height="100%" cellspacing="0" cellpadding="0">
<tr height=40>
<td>
<table cellspacing="1" cellpadding="1" width=400>
<tr align=middle>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)"
onmouseup="check(this,1)" title="粗体" onclick="doformat('bold','','b')">
<img src="../htmleditor/images/b.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="斜体"
onclick="doformat('italic','','i')">
<img src="../htmleditor/images/i.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="下划线"
onclick="doformat('underline','','u')"><img src="../htmleditor/images/u.gif"
width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="撤销"
onclick="doformat('undo','','')">
<img src="../htmleditor/images/undo.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="恢复"
onclick="doformat('redo','','')"><img src="../htmleditor/images/redo.gif"
width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="左对齐"
onclick="doformat('justifyleft','','p align=left')"
><img src="../htmleditor/images/left.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="居中"
onclick="doformat('justifycenter','','p align=center')"
><img src="../htmleditor/images/center.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="右对齐"
onclick="doformat('justifyright','','p align=right')"
><img src="../htmleditor/images/right.gif" width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="剪切"
onclick="doformat('cut','','')"><img src="../htmleditor/images/cut.gif"
width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="复制"
onclick="doformat('copy','','')"><img src="../htmleditor/images/copy.gif"
width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="粘贴"
onclick="doformat('paste','','')">
<img src="../htmleditor/images/paste.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="删除"
onclick="doformat('delete','','')">
<img src="../htmleditor/images/delete.gif" width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="插入链结"
onclick="doformat('createlink','','')"><img src="../htmleditor/images/link.gif"
width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="添加附件"
onclick="insertattach();"
><img src="../htmleditor/images/upfile.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="插入图片"
onclick="insertimage()"><img src="../htmleditor/images/image.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)"
title="插入表格" onclick="addtable()">
<img src="images/table.gif" width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="背景颜色"
onclick="doformat('backcolor',bkcolorimg.style.backgroundcolor+'',
'font style=background-color:'+bkcolorimg.style.backgroundcolor)"
width="18"><img id=bkcolorimg style="background-color: #ffffff"
src="images/colorpen.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="选择背景颜色"
style="font-weight: normal; font-size: 5pt" onclick="selectcolor(bkcolorimg)" width="7"
>▼</td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="字体颜色"
onclick="doformat('forecolor',colorimg.style.backgroundcolor+'',
'font color='+colorimg.style.backgroundcolor)" width="18">
<img id=colorimg style="background-color: #000000"
src="images/fontcolor.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="选择字体颜色"
style="font-weight: normal;
font-size: 5pt; line-height: normal; font-style: normal;
font-variant: normal" onclick="selectcolor(colorimg)" width="7">▼</td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="帮助"
onclick="showhelp()"><img src="images/help.gif" width="16" height="16"></td>
</tr>
</table>
<table cellspacing="1" cellpadding="1" width="400">
<tr align=middle>
<td width="60">
<select id="select1" style="width: 60; height: 20"
onchange="doselectclick('formatblock',this,this.value);
this.returnvalue=false;" name="select1" size="1">
<option selected value="">(标题)</option>
<option value="pre">pre<option value="h1">h1
<option value="h2">h2<option value="h3">h3
<option value="h4">h4<option value="h5">h5
<option value="h6">h6<option value="h7">h7
</select></td>
<td width="80">
<select style="width: 80; height: 20"
onchange="doselectclick('fontname',this,'font face="'+this.value+'"')"
name="selectfontname"
size="1">
<option selected>(字体)</option>
<option value="arial">arial</option>
<option value="arial black">arial black</option>
<option value="arial narrow">arial narrow</option>
<option value="ms outlook">ms outlook</option>
<option value="宋体">宋体<option value="楷体_gb2312">楷体
<option value="隶书">隶书<option value="黑体">黑体
<option value="仿宋_gb2312">仿宋</option>
</select></td>
<td width="60"><select style="width: 60; height: 20"
onchange="doselectclick('fontsize',this,'font size='+this.value);"
name="selectfontsize" size="1">
<option selected>(大小)</option>
<option value="1">1<option value="2">2<option value="3">3
<option value="4">4<option value="5">5<option value="6">6
<option value="7">7</option></select></td>
<td width="80"><select id="otherformat"
style="width: 75; height: 20" onchange="doselectclick('formatblock',this,this.value);
this.returnvalue=false;" size="1" name="selectfoontformat">
<option selected>(格式)</option><option value="sup">上标
<option value="sub">下标<option value="del">删除线<option value="big">增大字体
<option value="small">减小字体</option></select>
</td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="减小缩进"
onclick="doformat('outdent','','')" width="16"><img src="images/outdent.gif"
width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="增加缩进"
onclick="doformat('indent','','blockquote')" width="16">
<img src="images/indent.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="插入水平线"
onclick="doformat('inserthorizontalrule','','hr')" width="16" >
<img src="images/hr.gif" width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="编号"
onclick="doformat('formatblock','<ol>','ol')" width="16">
<img src="images/ol.gif" width="16" height="16"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="项目符号"
onclick="doformat('formatblock','<ul>','ul')" width="16">
<img src="images/ul.gif" width="16" height="16"></td>
<td width="4"><img src="images/separator.gif" width="4" height="18"></td>
<td class=none onmousedown=check(this,2) onmouseover="check(this,1)"
onmouseout="check(this,0)" onmouseup="check(this,1)" title="去除格式"
onclick="doformat('removeformat','','')" width="16">
<img src="images/unformat.gif" width="16" height="16"></td>
</tr>
</table>
</td>
</tr>
<tr height="100%" width="100%">
<td>
<iframe id="editor" name="editor" style="width: 100%; height: 100%"></iframe>
</td>
</tr>
<tr height=15>
<td height=15>
<map name="map">
<area shape="rect" coords="51,1,92,15" href="#" onclick="return(selectformat('html'));">
<area shape="rect" coords="93,1,133,15" href="#" onclick="return(selectformat('preview'));" >
</map>
<map name="map2">
<area shape="rect" coords="6,1,45,16" href="#" onclick="return(selectformat('normal'));" >
<area shape="rect" coords="93,1,133,15" href="#" onclick="return(selectformat('preview'));">
</map>
<map name="map3">
<area shape="rect" coords="5,1,47,15" href="#" onclick="return(selectformat('normal'));">
<area shape="rect" coords="47,2,90,15" href="#" onclick="return(selectformat('html'));">
</map>
<div id=normal>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=15>
<tr>
<td align="left"><img src="../htmleditor/images/normal.gif"
usemap=#map border=0 width="135" height="15">
</td>
<td align="middle"><img src="../htmleditor/images/scrolll.gif"
border=0 width="24" height="15"></td>
<td align="middle" width="100%" style="filter: alpha(opacity=50); background-color: white"
></td>
<td align="right"><img src="../htmleditor/images/scrollr.gif"
border=0 width="19" height="15"></td>
</tr>
</table>
</div>
<div id=html style="display: none">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=15>
<tr>
<td align="left"><img src="../htmleditor/images/html.gif"
usemap=#map2 border=0 width="135" height="15">
</td>
<td align="middle"><img src="../htmleditor/images/scrolll.gif"
border=0 width="24" height="15"></td>
<td align="middle" width="100%" style="filter: alpha(opacity=50);
background-color: white"
></td>
<td align="right"><img src="../htmleditor/images/scrollr.gif"
border=0 width="19" height="15"></td>
</tr>
</table>
</div>
<div id=preview style="display: none">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=15>
<tr>
<td align="left"><img src="../htmleditor/images/preview.gif"
usemap=#map3 border=0 width="135" height="15"></td>
<td align="middle"><img src="../htmleditor/images/scrolll.gif"
border=0 width="24" height="15"></td>
<td align="middle" width="100%" style="filter: alpha(opacity=50);
background-color: white"
></td>
<td align="right"><img src="../htmleditor/images/scrollr.gif"
border=0 width="19" height="15"></td>
</tr>
</table>
</div>
</td></tr></table>
</body>
|