http://download.csdn.net/source/2062506

参考了早期126邮件编辑器以及网上一些资料。图片资源主要来自网络。

代码部分只有一个html文件。其余为图标。

代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META name=GENERATOR content="MSHTML 8.00.6001.18828">
</HEAD>
<STYLE type=text/css>
DIV A.n {PADDING: 2px; DISPLAY: block; COLOR: #000000; LINE-HEIGHT: 16px; HEIGHT: 16px; TEXT-DECORATION: none}
DIV A.n:hover {BACKGROUND: #e5e5e5}

.as1{margin:1px;border:2px solid #9EC9EC;background-color:#E5E8E8;font-size:12px;cursor:pointer;}
.as2{margin:1px;border:2px solid #E5E8E8;background-color:#E5E8E8;cursor:pointer;}
</STYLE>

<INPUT language=javascript  οnclick='setMode(this.checked);menu.style.display = (this.checked)?"none":""' type=checkbox id=switchMode>HTML
<DIV id=menu style="background:#E5E8E8;BORDER: #c5c5c5 1px solid;" >
<IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Cut.gif"  title=剪切 onClick="format('Cut')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Copy.gif"  title=复制 onClick="format('Copy')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Paste.gif"  title=粘贴 onClick="format('Paste')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Undo.gif" title=撤消 onClick="execCommand('undo')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Redo.gif" title=重做 onClick="execCommand('Redo')" ><IMG src="aline.gif"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="TX.gif"  title=清除格式 onClick=format("removeFormat") ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="a4.gif"  title=字体 onClick='fDisplay("fontface")' ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="a5.gif"  title=字号 onClick="fDisplay('fontsize')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="a16.gif" title=字体颜色 οnclick='gSetColorType="foreColor";fSetColor();fDisplay("dvForeColor");' ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="a17.gif" title=背景颜色 οnclick='gSetColorType="backcolor";fSetColor();fDisplay("dvForeColor");' ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Bold.gif"  title=加粗 onClick="format('Bold');"  ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Italic.gif"  title=斜体 onClick="format('Italic');" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Underline.gif"  title=下划线 onClick="format('Underline')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="DelLine.gif"  title=删除线 onClick="format('strikethrough')"><IMG src="aline.gif"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Left.gif"  title=左对齐 onClick="format('Justifyleft')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Center.gif" title=中间对齐 onClick="format('Justifycenter')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Right.gif" title=右对齐 onClick="format('Justifyright')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="NumberList.gif" title=数字编号 onClick="format('Insertorderedlist')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="List.gif" title=项目编号 onClick="format('Insertunorderedlist')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Outdent.gif" title=减少缩进 onClick="format('Outdent')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Indent.gif" title=增加缩进 onClick="format('Indent')" ><IMG src="aline.gif"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Link.gif" title=添加链接 οnclick=createLink() ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Unlink.gif" title=去掉链接 οnclick="format('UnLink')"><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Line.gif" title=插入水平线 οnclick="format('InsertHorizontalRule')" ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Img.gif" title=插入图片 οnclick='fDisplay("InsertImageDiv")' ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Table.gif"title=插入表格 οnclick='fDisplay("excelDiv")' ><IMG class="as2" onMouseOver="this.className='as1';" onMouseOut="this.className='as2'" src="Code.gif"title=插入代码域或转化选中为代码域 οnclick=code() >
</DIV>

<DIV id=dvForeColor style="DISPLAY: none; WIDTH: 100px; POSITION: absolute;  HEIGHT: 100px" οnclick='format(gSetColorType, event.srcElement.parentNode.bgColor);this.style.display = "none"'
onmousemove ='document.getElementById("tdView").bgColor = event.srcElement.parentNode.bgColor;document.getElementById("tdColorCode").innerHTML = event.srcElement.parentNode.bgColor;'>
<TABLE style="BORDER-RIGHT: #888888 1px solid; BORDER-TOP: #888888 1px solid; BORDER-LEFT: #888888 1px solid; BORDER-BOTTOM: #888888 1px solid" height=25 cellSpacing=0 cellPadding=0 width=218>
<TBODY>
<TR>
<TD id=tdView width=110>&nbsp;</TD>
<TD id=tdColorCode align=middle bgColor=#ffffff></TD>
</TR>
</TBODY>
</TABLE>
</DIV>

<DIV id=fontface style="BORDER-RIGHT: #838383 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #838383 1px solid; DISPLAY: none; PADDING-LEFT: 1px; Z-INDEX: 99; BACKGROUND: #ffffff; LEFT: 2px; PADDING-BOTTOM: 1px; BORDER-LEFT: #838383 1px solid; WIDTH: 110px; PADDING-TOP: 1px; BORDER-BOTTOM: #838383 1px solid; POSITION: absolute; TOP: 35px; HEIGHT: 270px" οnkeydοwn='if(event.keyCode==27)this.style.display = "none"'>
<A class=n style="FONT: 12px '宋体'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">宋体</A>
<A class=n style="FONT: 12px '黑体'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">黑体</A>
<A class=n style="FONT: 12px '楷体'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">楷体</A>
<A class=n style="FONT: 12px '隶书'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">隶书</A>
<A class=n style="FONT: 12px '幼圆'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">幼圆</A>
<A class=n style="FONT: 12px Arial"  onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Arial</A>
<A class=n style="FONT: 12px 'Arial Narrow'"    onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Arial Narrow</A>
<A class=n style="FONT: 12px 'Arial Black'"     onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Arial Black</A>
<A class=n style="FONT: 12px 'Comic Sans MS'"   onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Comic Sans MS</A>
<A class=n style="FONT: 12px Courier"           onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Courier</A>
<A class=n style="FONT: 12px System"            onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">System</A>
<A class=n style="FONT: 12px 'Times New Roman'" onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Times New Roman</A>
<A class=n style="FONT: 12px Verdana"           onClick="format('fontname',this.innerHTML);this.parentNode.style.display='none'" href="javascript:void(0)">Verdana</A>
</DIV>

<DIV id=fontsize style="BORDER-RIGHT: #838383 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #838383 1px solid; DISPLAY: none; PADDING-LEFT: 1px; BACKGROUND: #ffffff; LEFT: 26px; PADDING-BOTTOM: 1px; BORDER-LEFT: #838383 1px solid; WIDTH: 115px; PADDING-TOP: 1px; BORDER-BOTTOM: #838383 1px solid; POSITION: absolute; TOP: 35px; HEIGHT: 160px" οnkeydοwn='if(event.keyCode==27)this.style.display = "none"'>
<A class=n style="FONT-SIZE: xx-small;LINE-HEIGHT: 120%" onClick="format('fontsize',1);this.parentNode.style.display='none'" href="javascript:void(0)">极小</A>
<A class=n style="FONT-SIZE: x-small; LINE-HEIGHT: 120%" onClick="format('fontsize',2);this.parentNode.style.display='none'" href="javascript:void(0)">特小</A>
<A class=n style="FONT-SIZE: small;   LINE-HEIGHT: 120%" onClick="format('fontsize',3);this.parentNode.style.display='none'" href="javascript:void(0)">小</A>
<A class=n style="FONT-SIZE: medium;  LINE-HEIGHT: 120%" onClick="format('fontsize',4);this.parentNode.style.display='none'" href="javascript:void(0)">中</A>
<A class=n style="FONT-SIZE: large;   LINE-HEIGHT: 120%" onClick="format('fontsize',5);this.parentNode.style.display='none'" href="javascript:void(0)">大</A>
<A class=n style="FONT-SIZE: x-large; LINE-HEIGHT: 120%" onClick="format('fontsize',6);this.parentNode.style.display='none'" href="javascript:void(0)">特大</A>
<A class=n style="FONT-SIZE: xx-large;LINE-HEIGHT: 140%" onClick="format('fontsize',7);this.parentNode.style.display='none'" href="javascript:void(0)">极大</A>
</DIV>

<DIV id=excelDiv οnkeydοwn='if(event.keyCode==13)excelok.click();if(event.keyCode==27)hideexcel.click();' style="DISPLAY: none; WIDTH:140px;POSITION: absolute; BORDER:2px solid #c3c9cf;PADDING: 1px;BACKGROUND:#f8f8f8">
<table style="margin:10px 10px 5px 10px">
<tr align=center><td colspan="2" style="font-size:15px;color:#777;background-color:#eee;">插入表格</td></tr>
<tr><td style="font-size:12px;color:#777;">行数</td><td style="font-size:12px"><input style="border:1px solid #69f;width:80px;height:14px;line-height:12px;font-size:12px;" id="exlrows" value="3" /> </td></tr>
<tr><td style="font-size:12px;color:#777;">列数</td><td style="font-size:12px"><input style="border:1px solid #69f;width:80px;height:14px;line-height:12px;font-size:12px;" id="exlcols" value="5" /> </td></tr>
<tr><td style="font-size:12px;color:#777;">宽度</td><td style="font-size:12px"><input style="border:1px solid #69f;width:80px;height:14px;line-height:12px;font-size:12px;" id="exlwidth" value="300" /> </td></tr>

<tr><td colspan="2" style="font-size:12px;color:#777;text-align:center;padding-top:6px;">
<input style="font-size:12px;color:#777;border:1px solid #777;background-color:#f4f4f4;margin-right:10px;" type="button" id=excelok onClick='InitTable(exlrows.value,exlcols.value,exlwidth.value);document.getElementById("excelDiv").style.display = "none"' value="插入" />
<input style="font-size:12px;color:#777;border:1px solid #777;background-color:#f4f4f4;" type="button" id=hideexcel onClick='document.getElementById("excelDiv").style.display = "none"'; value="取消" />
</td></tr>
</table>
</DIV>

<DIV id=InsertImageDiv οnkeydοwn='if(event.keyCode==13)InsertImage.click();if(event.keyCode==27)hideInsertImageDiv.click();' style="DISPLAY: none; WIDTH:240px;POSITION: absolute; BORDER:2px solid #c3c9cf;PADDING: 1px;BACKGROUND:#f8f8f8">
<table style="margin:10px 10px 5px 10px">
<tr align=center><td colspan="2" style="font-size:15px;color:#777;background-color:#eee;padding-top:6px;">插入图片</td></tr>
<tr><td colspan="2" style="display:none"><input id="fileInsertImage" type="file" > </td></tr>
<tr><td><input id=file2InsertImage value="" οnfοcus="select()""border:1px solid #69f;width:80px;height:14px;line-height:12px;font-size:12px;">  </td><td>
<input style="font-size:12px;color:#777;border:1px solid #777;background-color:#f4f4f4;" type="button" value="浏览..." onClick="fileInsertImage.click();file2InsertImage.value=fileInsertImage.value"></td></tr>
<tr><td colspan="2" style="font-size:12px;color:#777;text-align:center;padding-top:6px;"><input id=InsertImage style="font-size:12px;color:#777;border:1px solid #777;background-color:#f4f4f4;"  type="button" value="插入" onClick='if(file2InsertImage.value)format("InsertImage",file2InsertImage.value);hideInsertImageDiv.click();'>
<input id=hideInsertImageDiv style="font-size:12px;color:#777;border:1px solid #777;background-color:#f4f4f4;" type="button" onClick='document.getElementById("InsertImageDiv").style.display = "none"'; value="取消" />
</td></tr>
</table>
</DIV>

<iframe ID="HtmlEditor"  marginHeight=0 marginWidth=0 width="100%" height="490px" frameBorder="1"style="border:0px"></iframe>

<textarea ID="sourceEditor" style="height:520px;width:100%;;background:#F2F1D7;display:none">
</textarea>

<input type="button" value="预览" onClick="test()"> 
<input type="button" value="清除" onClick="reset()"> 
<input type="button" value="复制全部" onClick="CopyAll()">
<input type="button" value="选中全部" onClick="selectAll()">
<input type="button" value="另存为" onClick="saveFile()">
<input type="button" value="修正本地url" onClick="xiuzheng()">
<input type="button" value="图片原始链接,双击打开" onClick="imgsrc2()">
<input type="button" value="标题示例" onClick='settitle("5656565")'>
<input type="button" contenteditable="ture" value="原始链接" onClick='getalink("http://379184514.com")'>
<input type="button" value="相关文件" onClick='getfile("filename")'>

<input id="fileImage" type="file" style="display:none">
<input id=file2 value="" οnfοcus="select()"> 
<input type="button" value="浏览..." onClick="fileImage.click();file2.value=fileImage.value"> 
<input type="button" value="载入" onClick='document.getElementById("HtmlEditor").src=file2.value'>

<input style="display:none" type="button" value="imgsrc测试" onClick="imgsrc()">
<input style="display:none" type="button" value="载入2" onClick='jseval("document/.getElementById/(/"HtmlEditor/"/)/.src/=/"D/:00/.htm/"")'>
<input style="display:none" type="button" value="Html" onClick='alert(window.frames["HtmlEditor"].document.getElementsByTagName("html")[0].innerHTML);'>
<input style="display:none" type="button" value="imgURLs" onClick="getIframeImgURL()">
<input style="display:none" type="button" value="sourceEditor" onClick='alert(document.getElementById("sourceEditor").innerText)'>
<input style="display:none" type="button" value="HtmlEditor" onClick='alert(window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML)'>
</BODY>
<SCRIPT language="javascript">
function openfile(nn)
{
document.getElementById("HtmlEditor").src=nn;
}
var gSetColorType="";
function init()
{
  window.frames["HtmlEditor"].document.write('<HTML><HEAD><TITLE>379184514</TITLE><style>body{padding-top:3px;padding-left:3px;padding-right:0px;margin:0px}p {margin:0;padding:0;}</style></HEAD><BODY></BODY></HTML>');
  window.frames["HtmlEditor"].document.designMode="on";
}
init();
function format(type, para)
{
 var f = window.frames["HtmlEditor"];
 f.focus();
 f.document.execCommand(type,false,para);
}
function setMode(bStatus)
{
 var sourceEditor = document.getElementById("sourceEditor");
 var HtmlEditor = document.getElementById("HtmlEditor");
 var f = window.frames["HtmlEditor"];
 var body = f.document.getElementsByTagName("BODY")[0];
  if(bStatus)
  {
    sourceEditor.style.display = "";
    HtmlEditor.style.display = "none";
    var cont =window.HtmlEditor.document.getElementsByTagName("html")[0].innerHTML;
    var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
    //正则特殊字符,$( )*+.[]?/^{}|,如果目录中存在则正则表达式替换不能执行,目录中可能出现的特殊字符有$( )+.[]^{}
  url=url.replace("//","").replace("/$","///$").replace("/(","///(").replace("/)","///)").replace("/+","///+").replace("/.","///.").replace("/[","///[").replace("/]","///]").replace("/^","///^").replace("/{","///{").replace("/}","///}");

var r = new RegExp(url,"gi");
    cont= cont.replace(r,"");
    document.getElementById("sourceEditor").innerText=cont;
 }
 else
 {
  sourceEditor.style.display = "none";
  HtmlEditor.style.display = "";
    body.innerHTML = sourceEditor.value;
 }
}

function InitTable(rows,cols,width)

  var builder='<table border="1" width="'+width+'">';
  for(var r = 0; r < rows; r++)
  {
    builder+=('<tr>');
    for(var c = 0; c < cols; c++)
    {
      builder+=('<td>&nbsp;</td>');
    }
    builder+=('</tr>');
  }
  builder+=('</table>');
 //window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML+= builder;
  var f = window.frames["HtmlEditor"];
 f.focus();
 f.document.selection.createRange().pasteHTML(builder);//在光标处插入
}

function fDisplay(idDiv)
{
 var idDiv =document.getElementById(idDiv);

var iX = window.event.clientX;
 var iY = window.event.clientY;
 idDiv.style.display = "";
 idDiv.style.left = (iX-40) + "px";
 idDiv.style.top = (iY-10) + "px";
 idDiv.focus();
}

function createLink()
{
 var sURL=window.prompt("输入链接地址", "");
 if ((sURL!=null))format("CreateLink", sURL);
}

var i=0;
function test()
{
  if(switchMode.checked == true)setMode(0);
  temp = window.frames["HtmlEditor"].document.getElementsByTagName("html")[0].innerHTML;
  testwin=open("","testwin","");
  testwin.document.open();
  testwin.document.write(temp);
  testwin.document.close();
}
function saveFile()
{
  if(switchMode.checked == true)setMode(0);
  temp = window.frames["HtmlEditor"].document.getElementsByTagName("html")[0].innerHTML;
  var win=window.open("","win","height=10, width=10,top=10,left=10,alwaysLowered=yes");
  win.document.write(temp);
  win.document.execCommand('SaveAs','','copy.htm');
  win.close();
}

function CopyAll()
{
  window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].createTextRange().execCommand("Copy")
  alert("复制成功!");
}

function selectAll()
{
  window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].createTextRange().select();
}

function reset()
{
 window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML = "";
}

function code()
{
  if(document.frames("HtmlEditor").document.selection && document.frames("HtmlEditor").document.selection.createRange)
  {
    var f = window.frames["HtmlEditor"];
    f.focus();
    ss=document.frames("HtmlEditor").document.selection.createRange().htmlText;
    window.frames["HtmlEditor"].document.execCommand("InsertTextArea",false,"code"+i);
  
    ff=document.frames("HtmlEditor").document.getElementById("code"+i);
    ff.value=ss;
    ff.wrap="off";
    //ff.rows="6";
    //ff.style.height="100px";
    ff.style.width="90%";
    ff.style.background="#F2F1D7";
    ff.style.borderRight="1px #F3F8FC solid";
    ff.style.overflowY="visible";//自适应高度
    ff.readonly="true";

i++;
    ff.focus();
  }
}
function getalink(savefrom)
{
  var alink=document.frames("HtmlEditor").document.getElementById("原始链接")
  if(alink==null)HtmlEditor.document.body.innerHTML+='<br><A id=原始链接 TARGET="_blank">0</A>';
  alink=document.frames("HtmlEditor").document.getElementById("原始链接")
  alink.href=savefrom
  alink.innerHTML='<FONT style="BACKGROUND-COLOR: #00ff00" color=#ff0033 size=5>原始链接:'+alink.href+"</FONT>"

//  alert(alink.id);
 // alert(alink.innerText.replace("原始链接:",""));
 // alert(alink.href);
}  
function getfile(filename)
{
var alink=document.frames("HtmlEditor").document.getElementById("相关文件")
if(alink==null)HtmlEditor.document.body.innerHTML+='<br><A id=相关文件 TARGET="_blank">0</A>';
alink=document.frames("HtmlEditor").document.getElementById("相关文件")
alink.href=filename
alink.innerHTML='<FONT style="BACKGROUND-COLOR: #000033"color=#ffff33><STRONG>相关文件:</STRONG></FONT><FONT color=#0000ff>'+alink.href+"</FONT>"


function jseval(x)
{  
  return eval(x);//返回值为x中的最后一行的结果。
}
function settitle(x)
{  
  window.frames["HtmlEditor"].document.title=x;
  return window.frames["HtmlEditor"].document.getElementsByTagName("title")[0].innerHTML;
}  
  
function edithtml()
{  
  return window.frames["HtmlEditor"].document.getElementsByTagName("html")[0].innerHTML;
}

function xiuzheng()
{
  var cont=document.getElementById("sourceEditor").innerText; 
  var url=//"res://D://WebVampire2(判断下载,增加大部分编辑器功能,菜单函数,添加,重做)//Release//WebVampire.exe/"
location.href.substring(0,location.href.lastIndexOf("/")+1);
  alert(url);
  //正则特殊字符,$( )*+.[]?/^{}|,如果目录中存在则正则表达式替换不能执行,目录中可能出现的特殊字符有$( )+.[]^{}
  url=url.replace("//","").replace("//","").replace("/$","///$").replace("/(","///(").replace("/)","///)").replace("/+","///+").replace("/.","///.").replace("/[","///[").replace("/]","///]").replace("/^","///^").replace("/{","///{").replace("/}","///}");
  var r = new RegExp(url,"gi");
  cont= cont.replace(r,"");
  document.getElementById("sourceEditor").innerText=cont;
}

function imgsrc()
{
  var imgs=document.frames("HtmlEditor").document.getElementsByTagName("img");
  for(var i = 0;i<imgs.length;i++)
  {
    imgs[i].alt="a"+(i+1)+".gif"
    imgs[i].title="双击查看原图"
    imgs[i].OnDblClick="window.open(this.alt)"
  }
}
function imgsrc2()
{
  var imgs=document.frames("HtmlEditor").document.getElementsByTagName("img");
//alert(imgs[0].src.slice(imgs[0].src.lastIndexOf("//")));
  for(var i = 0;i<imgs.length;i++)
  {
    if(imgs[i].src.slice(0,4)=="http")//防止重复操作
    {
      var srctmp=imgs[i].src;
      imgs[i].src="data:image"+imgs[i].src.slice(imgs[i].src.lastIndexOf("//"));
      imgs[i].alt=srctmp;
      imgs[i].title="双击查看原图";
      imgs[i].OnDblClick="window.open(this.alt)";
    }
    //else alert(imgs[0].src.slice(0,4))
  }
}

function getIframeImgURL()
{
  var imgs=document.frames("HtmlEditor").document.getElementsByTagName("img");
  //var imgs = document.getElementsByTagName("img");
  var imgURLs=new Array(imgs.length);
  for(var i = 0;i<imgs.length;i++)
  {
     imgURLs[i] = imgs[i].src;//如果用document.getElementsByTagName("img")[i].src;每取一个图片地址就会对全部图片查找一次,这样效率比较低,还是储存在imgs中比较好!
  }
//以上代码最好放在页面的最后面,或window.onload事件里,这样就不会因为页面没有全部加载完而没有全部读取到img元素
  //alert(imgURLs);
  return imgURLs.join(" ");
}
</SCRIPT>

<script language="JavaScript">
// Draw color selector
var s = "";
var hex = new Array(6)
hex[0] = "FF"
hex[1] = "CC"
hex[2] = "99"
hex[3] = "66"
hex[4] = "33"
hex[5] = "00"
function drawCell(red, green, blue)
{
 var color = '#' + red + green + blue;
 s += '<TD BGCOLOR="' + color + '" style="height:12px;width:12px;" >';
 s += '<IMG '+ ((document.all)?"":"src='place.gif'") +' HEIGHT=12 WIDTH=12>';
 s += '</TD>';
}
function drawRow(red, blue)
{
 s += '<TR>';
 for (var i = 0; i < 6; ++i)
 {
  drawCell(red, hex[i], blue)
 }
 s += '</TR>';
}
function drawTable(blue)
{
 s += '<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>';
 for (var i = 0; i < 6; ++i)
 {
  drawRow(hex[i], blue)
 }
 s += '</TABLE>';
}
function drawCube()
{
 s += '<TABLE CELLPADDING=0 CELLSPACING=0 style="border:1px #888888 solid"><TR>';
 for (var i = 0; i < 3; ++i)
 {
  s += '<TD BGCOLOR="#FFFFFF">';
  drawTable(hex[i])
  s += '</TD>';
 }
 s += '</TR><TR>';
 for (var i = 3; i < 6; ++i)
 {
  s += '<TD BGCOLOR="#FFFFFF">';
  drawTable(hex[i])
  s += '</TD>';
 }
 s += '</TR></TABLE>';
 return s;
}
function fSetColor()
{
 var dvForeColor =document.getElementById("dvForeColor");
 if(dvForeColor.getElementsByTagName("TABLE").length == 1)
 {
  dvForeColor.innerHTML = drawCube() + dvForeColor.innerHTML;
 }
}
</script>

束!

HTML在线编辑器(HTML+js)相关推荐

  1. 图形化开发(一)——Three.js基本介绍-优缺点-在线编辑器 Babylon.JS是最好的JavaScript3D游戏引擎

    图形化开发(一)--Three.js基本介绍-优缺点-在线编辑器 & Babylon.JS是最好的JavaScript3D游戏引擎 课程主要学习目标 Threejs ( 3d ) D3 (做数 ...

  2. HTML5在线编辑器Wysihtml5之Bootstrap扩展

    为什么80%的码农都做不了架构师?>>>    HTML5在线编辑器Wysihtml5之Bootstrap扩展 bootstrap扩展后的效果 Wysihtml5在线编辑器 boot ...

  3. 百度在线编辑器 显示html,UEditor百度编辑器中JS/html代码(script标签)被过滤的解决办法...

    作为一名程序员,在文章中经常会插入各种代码,大部分代码都不会发生问题,但div和script标签是经常会被使用到的. 而在之前的文章编写过程中,插入JS代码后,第一次文章会显示正常,而之后在后台编辑器 ...

  4. JS设计“网页在线编辑器”

    为扩充佳誉网站管理软件的实际功能,今天大致性的设计了一个所见即所得的网页在线编辑器,只做了个雏形出来,目前所能做的仅仅是在"编辑"状态下写入HTML代码,在"预览&quo ...

  5. ASP.net:添加.net(2.0C#)FCKeditor在线编辑器步骤

    1.下载本版本的编辑器压缩包.源码下载地址 2.解压缩打开文件夹拥有如下文件: 3.在VS中添加"选择项"加载在此文件夹的Bin下FredCK.FCKeditorV2.dll. 4 ...

  6. 自己开发的MarkDown在线编辑器越来越完善了,心里感到高兴。

    先晒一下它的样子.当然,我一开始就企图做到这四点:随时随地可以自动保存草稿内容到服务器:键盘快捷键进行Markdown格式编辑:可以分段编辑(万一文章比较长呢):还有就是手机上也能用大部分功能.现在这 ...

  7. 基于ThinkPHP的在线编辑器调用

    开源的在线编辑器有很多,比如FCKEditor,UEditor,Kindeditor等,调用方式也都大同小异 下面列举UEditor在线编辑器插件在ThinkPHP里面的应用 1.Ueditor下载地 ...

  8. 5款非常好用的前端在线编辑器推荐

    使用在线编辑器的好处: I     提供各种在线JS或css框架 II    实时预览代码效果 III   线上保存代码 IIII  可分享 下面推荐几款很不错的在线前端编辑器 1.jsfiddle ...

  9. tinyMce在线编辑器内JavaScript实现按Ctrl+S无刷新保存

    以前也用过几个编辑器拉,如FCK,CUTEDTOR等,它们大都实现了很不错了的功能,也有丰富的插件使用.不过我还是觉得TinyMCE在线编辑器好用,它是采用纯JS客户端脚本技术构建,是一个轻量级加载速 ...

  10. jquery插件课程2 放大镜、多文件上传和在线编辑器插件如何使用

    jquery插件课程2 放大镜.多文件上传和在线编辑器插件如何使用 一.总结 一句话总结:插件使用真的还是比较简单的,引包,初始化,配置参数(json),配置数据(json),而后两步不是必须的.而且 ...

最新文章

  1. Linux内核分析——可执行程序的装载
  2. 如何通过parent object ID获得underlying object structure IBASE ID
  3. saltstack的安装(转载连接)
  4. 高等数学上-赵立军-北京大学出版社-题解-练习5.7
  5. 信息抽取--关键句提取
  6. 2017.4.16 麦森数 思考记录
  7. NS2仿真过程中需要的语言及基本组件
  8. 8. 额外的并发实用程序(Additional Concurrency Utilities)
  9. Join()--用法
  10. 论文常用实验数据收集整理
  11. 虚拟机由于找不到msvcr120dll_计算机提示丢失msvcr120.dll文件怎么办?
  12. BUUCTF·[MRCTF2020]天干地支+甲子·WP
  13. uni-app三级联动笔记
  14. TexturePacker的用法
  15. 文化产业如何面对大数据时代
  16. 小米手环4无需密钥获取心率(JAVA,安卓)
  17. C语言 1999年标准
  18. 新中大SE(ngpower)记帐
  19. 3t硬盘分区 Linux win,大师为你解说3t硬盘分区【搞定步骤】_
  20. animation的使用-css无限旋转

热门文章

  1. 33的挑战状(bilibili首届安全挑战赛)
  2. GitHub的raw.githubusercontent.com无法链接
  3. 可解释机器学习-Task01-导论
  4. delegate的几种写法
  5. AMBA AXI 协议
  6. ios 10 简单配置
  7. 声网Q4亏损扩大1.6倍,持股4.9%的联合创始人陶思明离职
  8. “数据产品经理”的产品技能成长之路
  9. 将毫秒数转换成小时数、分钟数和秒数。
  10. 磊科nw336 linux驱动下载,磊科nw336无线网卡驱动下载