你看看这个吧!下面的代码复制过去就可以用!不过少几张图片!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0067)http://lucky.myrice.com/javascriptexam/htmleditor/editor/editor.htm -->
<HTML><HEAD><TITLE>HTML 编辑器</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE>BODY {
FONT-SIZE: 12px; FONT-FAMILY: 细明体
}
TD {
FONT-SIZE: 12px; FONT-FAMILY: 细明体
}
BUTTON {
FONT-SIZE: 12px; FONT-FAMILY: 细明体
}
INPUT {
FONT-SIZE: 12px; FONT-FAMILY: 细明体
}
DIV {
BORDER-RIGHT: #d9cec4 1px solid; BORDER-TOP: #d9cec4 1px solid; BACKGROUND: #d9cec4; BORDER-LEFT: #d9cec4 1px solid; WIDTH: 24px; CURSOR: default; BORDER-BOTTOM: #d9cec4 1px solid; HEIGHT: 20px; TEXT-ALIGN: center; borderColor: #ffffff
}
.function {
WIDTH: 80px
}
</STYLE><SCRIPT>
function BtnOver(btn){
btn.style.borderTopColor="#efece8";
btn.style.borderBottomColor="#888070";
btn.style.borderLeftColor="#efece8";
btn.style.borderRightColor="#888070";
}
function BtnClick(btn){
btn.style.borderTopColor="#888070";
btn.style.borderBottomColor="#efece8";
btn.style.borderLeftColor="#888070";
btn.style.borderRightColor="#efece8";
}
function BtnOut(btn){
btn.style.borderColor="#d9cec4";
}
function doCut(){
doc.execCommand('Cut');
Editor.focus();
}
function doCopy(){
doc.execCommand('Copy');
Editor.focus();
}
function doPaste(){
doc.execCommand('Paste');
Editor.focus();
}
function doUndo(){
doc.execCommand('Undo');
Editor.focus();
}
function doDelete(){
doc.execCommand('Delete');
Editor.focus();
}
function doFontName(fn){
doc.execCommand('FontName', false, fn);
Editor.focus();
}
function doFontSize(fs){
doc.execCommand('FontSize', false, fs);
Editor.focus();
}
function doBold(){
doc.execCommand('Bold');
Editor.focus();
}
function doItalic(){
doc.execCommand('Italic');
Editor.focus();
}
function doUnderline(){
doc.execCommand('Underline');
Editor.focus();
}
function doStrikeThrough(){
doc.execCommand('StrikeThrough');
Editor.focus();
}
function doSubscript(){
doc.execCommand('Subscript');
Editor.focus();
}
function doSuperscript(){
doc.execCommand('Superscript');
Editor.focus();
}
function doJustifyLeft(){
doc.execCommand('JustifyLeft');
Editor.focus();
}
function doJustifyRight(){
doc.execCommand('JustifyRight');
Editor.focus();
}
function doJustifyCenter(){
doc.execCommand('JustifyCenter');
Editor.focus();
}
function doIndent(){
doc.execCommand('Indent');
Editor.focus();
}
function doOutdent(){
doc.execCommand('Outdent');
Editor.focus();
}
function doForeColor(){
var fcolor=showModalDialog("editor_color.htm",false,"dialogWidth:106px;dialogHeight:126px;status:0;");
doc.execCommand('ForeColor',false,fcolor);
Editor.focus();
}
function doBackColor(){
var bcolor=showModalDialog("editor_color.htm",false,"dialogWidth:106px;dialogHeight:126px;status:0;");
doc.execCommand('BackColor',false,bcolor);
Editor.focus();
}
function doInsertTable(){
var dotable=showModalDialog("editor_table.htm",false,"dialogWidth:200px;dialogHeight:156px;status:0;");
if (dotable!=undefined){
doc.body.innerHTML=doc.body.innerHTML+dotable;
}else{
return false;
}
Editor.focus();
}
function doInsertOrderedList(){
doc.execCommand('InsertOrderedList');
Editor.focus();
}
function doInsertUnorderedList(){
doc.execCommand('InsertUnorderedList');
Editor.focus();
}
function doCreateLink(){
doc.execCommand('CreateLink');
Editor.focus();
}
function doInsertImage(){
Editor.focus();
doc.execCommand('InsertImage','xxx');
}
function doInsertInputButton(){
Editor.focus();
doc.execCommand('InsertInputButton');
}
function doInsertHorizontalRule(){
Editor.focus();
doc.execCommand('InsertHorizontalRule');
}
function doInsertInputCheckbox(){
Editor.focus();
doc.execCommand('InsertInputCheckbox');
}
function doInsertInputRadio(){
Editor.focus();
doc.execCommand('InsertInputRadio');
}
function doInsertInputText(){
Editor.focus();
doc.execCommand('InsertInputText');
}
function doInsertInputPassword(){
Editor.focus();
doc.execCommand('InsertInputPassword');
}
function doInsertInputSubmit(){
Editor.focus();
doc.execCommand('InsertInputSubmit');
ShowMessage();
}
function doInsertInputReset(){
Editor.focus();
doc.execCommand('InsertInputReset');
ShowMessage();
}
function doInsertMarquee(){
Editor.focus();
doc.execCommand('InsertMarquee');
ShowMessage();
}
function doInsertSelectDropdown(){
Editor.focus();
doc.execCommand('InsertSelectDropdown');
}
function doInsertTextArea(){
Editor.focus();
doc.execCommand('InsertTextArea');
}
function doPrint(){
doc.execCommand('Print');
Editor.focus();
}
function doSaveAs(){
doc.execCommand('SaveAs',0,"未命名");
Editor.focus();
}
function doOpen(){
doc.execCommand('Open');
Editor.focus();
}
function EditResource(){
Preview.value=doc.body.innerHTML;
return false;
}
function ClearAll(){
doc.body.innerHTML='';
Preview.value='';
return false;
}
function SeePreview(){
doc.body.innerHTML=Preview.value;
return false;
}
function AutoPreview(){
if(vx.checked){
SeePreview();
}
}
function EditMode(){
doc.designMode = "On";
window.setTimeout('SeePreview()',100);
Preview.focus();
}
function PreviewMode(){
doc.designMode = "Off";
window.setTimeout('SeePreview()',100);
Preview.focus();
}
function ShowMessage(){
alert("请按两下物件编辑内容");
}
</SCRIPT>

解决方案 »

  1.   

    太多,分开发
    <META content="Microsoft FrontPage 5.0" name=GENERATOR></HEAD>
    <BODY onkeyup=AutoPreview(); bgColor=#e0e0e0>
    <CENTER>
    <TABLE cellSpacing=0 borderColorDark=#efece8 cellPadding=0 width=600 
    borderColorLight=#888070 border=1>
      <TBODY>
      <TR>
        <TD bgColor=#d9cec4>
          <TABLE cellSpacing=1 cellPadding=0 border=0>
            <TBODY>
            <TR>
              <TD><IMG src="HTML 编辑器_files/editor_h.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=存档 onclick=doSaveAs(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f01.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=列印 onclick=doPrint(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f02.gif" width="19" height="20"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=剪下 onclick=doCut(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f03.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=复制 onclick=doCopy(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f04.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=贴上 onclick=doPaste(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f05.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=删除 onclick=doDelete(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f06.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=复原 onclick=doUndo(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f07.gif" width="19" height="20"></DIV></TD></TR></TBODY></TABLE></TD></TR>
      <TR>
        <TD bgColor=#d9cec4>
          <TABLE cellSpacing=1 cellPadding=0 border=0>
            <TBODY>
            <TR>
              <TD><IMG src="HTML 编辑器_files/editor_h.gif" width="6" height="20"></TD>
              <TD><SELECT 
                onchange=doFontName(this[this.selectedIndex].value);this.selectedIndex=0;> 
                  <OPTION value="" selected>字型<OPTION value=细明体>细明体<OPTION 
                  value=新细明体>新细明体<OPTION value=标楷体>标楷体<OPTION 
                  value=arial>arial<OPTION 
              value=wingdings>wingdings</OPTION></SELECT></TD>
              <TD><SELECT 
                onchange=doFontSize(this[this.selectedIndex].value);this.selectedIndex=0;> 
                  <OPTION value="" selected>大小<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><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=粗体字 onclick=doBold(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f08.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=斜体字 onclick=doItalic(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f09.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=划底线 onclick=doUnderline(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f10.gif" width="19" height="18"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=删除线 onclick=doStrikeThrough(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f11.gif" width="19" height="18"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=上标字 onclick=doSuperscript(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f12.gif" width="19" height="18"></DIV></TD>
      

  2.   

    在发
             <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=下标字 onclick=doSubscript(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f13.gif" width="19" height="18"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=文字颜色 onclick=doForeColor(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f14.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=背景颜色 onclick=doBackColor(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f15.gif" width="19" height="20"></DIV></TD></TR></TBODY></TABLE></TD></TR>
      <TR>
        <TD bgColor=#d9cec4>
          <TABLE cellSpacing=1 cellPadding=0>
            <TBODY>
            <TR>
              <TD><IMG src="HTML 编辑器_files/editor_h.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=靠左对  onclick=doJustifyLeft(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f16.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=靠中对  onclick=doJustifyCenter(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f17.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=靠右对  onclick=doJustifyRight(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f18.gif" width="19" height="20"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=增加缩排 onclick=doIndent(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f19.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=减少缩排 onclick=doOutdent(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f20.gif" width="19" height="20"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=数字标题 onclick=doInsertOrderedList(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f21.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=无数字标题 
                onclick=doInsertUnorderedList(); onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f22.gif" width="19" height="20"></DIV></TD>
              <TD><IMG src="HTML 编辑器_files/editor_s.gif" width="6" height="20"></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=插入分隔线 
                onclick=doInsertHorizontalRule(); onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f23.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=插入表格 onclick=doInsertTable(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f24.gif" width="19" height="20"></DIV></TD>
              <TD>
                <DIV onmouseup=BtnOver(this); onmousedown=BtnClick(this); 
                onmouseover=BtnOver(this); title=插入连结 onclick=doCreateLink(); 
                onmouseout=BtnOut(this);>
                  <IMG 
                src="HTML 编辑器_files/editor_f25.gif" width="19" height="20"></DIV></TD>