网上下载了个网站系统,后台的内容编辑器自动换行不太好,代码都是js的,看得头晕。代码比较长,贴不上来,怎么办,请高人指点啊。

解决方案 »

  1.   

    贴代码//需要的基础变量
    var Asai_edit;
    var Asai_RangeType;
    var Asai_selection;
    var Asai_filterScript = false;
    var Asai_charset="gb2312";
    var Asai_bLoad=false;
    var Asai_pureText=true;
    var Asai_bTextMode=1;
    var Asai_colour;//这里是编辑器css的样式
    document.write('<body onLoad="return load_edit();">');
    document.write("<style>#PostiFrame{border:1px solid #"+sy+";padding:3px;font-size:12px;}.pm{padding:0px;margin:0px;}.stt{position:absolute;background-color:#"+by+";border:#"+sy+" 1px solid;font-size:12px;padding:5px;FILTER:alpha(opacity=88)progid:DXImageTransform.Microsoft.Shadow(Color=#"+sy+",Direction=120,strength=4);}.stt a{cursor:pointer;}.as1{margin:1px;border:1px solid #"+sy+";background-color:#"+qy+";font-size:12px;cursor:pointer;}.as2{margin:1px;border:1px solid #"+by+";cursor:pointer;}.Ab{margin:2px;float:left;width:66px;height:22px;line-height:22px;text-align:center;font-size:13px;cursor:pointer;border:1px solid #"+sy+";background-color: #"+qy+";}.Aba{margin:2px;float:left;width:66px;height:22px;line-height:22px;text-align:center;font-size:13px;font-weight:bold;cursor:pointer;border:1px solid #"+sy+";background-color: #"+by+";}#Ar{text-align:left;background-color:#"+by+";border-top:1px solid #"+sy+";border-left:1px solid #"+sy+";border-right:1px solid #"+sy+";padding:2px;}#Ac{border:1px solid #"+sy+";padding:2px;}#At{background-color:#"+by+";border-bottom:1px solid #"+sy+";border-left:1px solid #"+sy+";border-right:1px solid #"+sy+";padding:2px;height:27px;}.Aj{float:right;margin:2px;width:32px;height:22px;line-height:22px;text-align:center;cursor:pointer;border:1px solid #"+sy+";background-color: #"+qy+";}#asaifontselect{width:auto;float:left;}#asaifontselect select{margin:2px 1px 1px 1px ;padding:0px;height:20px;}</style>");//段落样式
    function Asai_FontHBsty(asty){
    if(asty==1){Asai_specialtype("<h1>","</h1>");}
    else if(asty==2){Asai_specialtype("<h2>","</h2>");}
    else if(asty==3){Asai_specialtype("<h3>","</h3>");}
    else if(asty==4){Asai_specialtype("<h4>","</h4>");}
    else if(asty==5){Asai_specialtype("<h5>","</h5>");}
    else if(asty==6){Asai_specialtype("<h6>","</h6>");}
    else if(asty==7){Asai_specialtype("<h7>","</h7>");}
    else if(asty==8){Asai_specialtype("<p>","</p>");}
    else if(asty==9){Asai_specialtype("<dd>","</dd>");}
    else if(asty==10){Asai_specialtype("<dt>","</dt>");}
    else if(asty==11){Asai_specialtype("<dir>","</dir>");}
    else if(asty==12){Asai_specialtype("<menu>","</menu>");}
    else if(asty==13){Asai_specialtype("<PRE>","</PRE>");}
    else if(asty==21){Asai_specialtype("<span style='width:100%;filter:blur(add=1, direction=45, strength=2)'>","</span>");}
    else if(asty==22){Asai_specialtype("<span style='width:100%;filter:glow(color=#ffff00, strength=10)'>","</span>");}
    else if(asty==23){Asai_specialtype("<span style='width:100%;filter:dropshadow(color=#999999, offx=2, offy=2, positive=1)'>","</span>");}
    else if(asty==24){Asai_specialtype("<SPAN style='BACKGROUND-IMAGE:URL(Logo.gif);'><DIV style='FILTER:Chroma(Color=#CCCCCC);COLOR:#CCCCCC; BACKGROUND-COLOR:#FFFFFF;font-size:66px;font-family:黑体;WIDTH:100%;'>","</DIV></SPAN>");}
    else if(asty==25){Asai_specialtype("<SPAN style='font-size:5px;cursor:pointer;' onmouseover= this.style.font='12px'; onmouseout= this.style.font='5px';>","</SPAN>");}
    else if(asty==26){Asai_specialtype("<span style='font-family:@宋体;'>","</span>");}
    else if(asty==27){Asai_specialtype("<span style='layout-flow:vertical-ideographic;float:right;'>","</span>");}
    else if(asty==28){Asai_specialtype("<span style='position:absolute;filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);float:right;'>","</span>");}
    else if(asty==29){Asai_specialtype("<SPAN style='FILTER:glow(color=red);width:100%;'>","</span>");}
    else if(asty==30){Asai_specialtype("<SPAN style='FILTER:blur;width:100%;'>","</span>");}
    else if(asty==31){Asai_specialtype("<SPAN style='FILTER:shadow(color=blue);width:100%;'>","</span>");}
    else if(asty==32){Asai_specialtype("<SPAN style='FILTER:alpha(opacity=10);width:100%;'>","</span>");}
    else if(asty==33){Asai_specialtype("<SPAN style='FILTER:dropshadow(color=D8D8D8);width:100%;'>","</span>");}
    else if(asty==91){Asai_specialtype("<div style='margin:18px;border:1px dotted #CCCCCC;padding:5px;background:#FDFDDF;font-size:12px;font-family:Tahoma;line-height:normal;cursor:pointer;' title='提示:点击运行该代码,观看即时演示!' onclick=\"preWin=window.open('','','');preWin.document.open();preWin.document.write(this.innerText);preWin.document.close();\">","</div>");}
    else if(asty==92){Asai_specialtype("<div style='margin:18px;border:1px dotted #CCCCCC;padding:5px;background:#EAF7EC;font-size:12px;font-family:Tahoma;line-height:normal;' title='提示:这是一段引用的内容!'>","</div>");}
    else if(asty==93){Asai_specialtype("<div style='text-align:center;clear:both;width:100%;'><div style='margin:8px 8px 8px 18px;border:#CCCCCC 1px solid;background-color:#F5F5F5;font-size:12px;width:180px;text-align:center;padding:8px;cursor:pointer;'><a onclick=AsaiTab.style.display='';><b>[ 显 示 ]</b></a> <a onclick=AsaiTab.style.display='none';><b>[ 隐 藏 ]</b></a></div><table id='AsaiTab' style='display:none;margin:18px;border:#CCCCCC 1px dotted;background-color:#F5F5F5;font-size:12px;' cellpadding='8' title='提示:这是一段隐藏的内容!'><tr><td align=left>","</td></tr></table></div>");}
    }//字体大小
    function Asai_FontHsize(asty){
    if(asty>7){Asai_specialtype("<font style='font-size:"+asty+"pt'>","</font>");}
    else{Asai_specialtype("<font size="+asty+">","</font>");}}//字体颜色
    function Asai_foreColor()
    {if (!Asai_validateMode()) return;
    if (Asai_bIsIE5){
    var arr = showModalDialog(""+Sm+""+Se+"HtmPop/selcolor.htm", "", "dialogWidth:299px; dialogHeight:300px; status:0; help:0");
    if (arr != null) FormatText('forecolor', arr);
    else AsaiIFrame.focus();
    }else
    {FormatText('forecolor', '');}}//字体背景
    function Asai_backColor()
    {if (!Asai_validateMode()) return;
    if (Asai_bIsIE5){
    var arr = showModalDialog(""+Sm+""+Se+"HtmPop/selcolor.htm", "", "dialogWidth:299px; dialogHeight:300px; status:0; help:0");
    if (arr != null) FormatText('backcolor', arr);
    else AsaiIFrame.focus();
    }else{FormatText('backcolor', '');}
    }// 粘贴纯文本
    function PasteText(){
    if (!Asai_validateMode()) return;
    AsaiIFrame.focus();
    var sText = HTMLEncode(clipboardData.getData("TEXT"));
    AsaiIFrame.document.body.innerHTML+=sText;
    AsaiIFrame.focus();}// HTMLEncode文本格式化
    function HTMLEncode(text){
    text = text.replace(/&/g, "&amp;") ;
    text = text.replace(/"/g, "&quot;") ;
    text = text.replace(/</g, "&lt;") ;
    text = text.replace(/>/g, "&gt;") ;
    text = text.replace(/'/g, "&#146;") ;
    text = text.replace(/\ /g,"&nbsp;");
    text = text.replace(/\n/g,"<BR>");
    text = text.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");
    return text;}//FLASH
    function Asai_forswf()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/swf.htm", "", "dialogWidth:333px; dialogHeight:240px; status:0; help:0");
    if (arr != null){
    var ss;
    ss=arr.split("*")
    path=ss[0];
    row=ss[1];
    col=ss[2];
    var string;
    string="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flashflash.cab#version=5,0,0,0' width="+row+" height="+col+"><param name=movie value="+path+"><param name=quality value=high><embed src="+path+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+row+" height="+col+"></embed></object>"AsaiIFrame.document.body.innerHTML+=string;
    }else AsaiIFrame.focus();}
    //wmv
    function Asai_forwmv()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/wmv.htm", "", "dialogWidth:333px; dialogHeight:300px; status:0; help:0");
    if (arr != null){
    var ss;
    ss=arr.split("*")
    path=ss[0];
    autostart=ss[1];
    width=ss[2];
    height=ss[3];
    ran=rand();
    var string;
    var ubbstring;
    string="<object align=center classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 hspace=5 vspace=5 width="+ width +" height="+ height +"><param name=Filename value="+ path +"><param name=ShowStatusBar value=1><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src="+ path +"  width="+ width +" height="+ height +"></embed></object>";
    string="<EMBED id=MediaPlayer"+ran+" src="+ path +" width="+ width +" height="+ height +" autostart=\""+ autostart +"\" loop=\"false\"></EMBED><p></p>";
    AsaiIFrame.document.body.innerHTML+=string;
    }else AsaiIFrame.focus();}
    //rm
    function Asai_forrm()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/rm.htm", "", "dialogWidth:333px; dialogHeight:290px; status:0; help:0");
    if (arr != null)
    {var ss;
    ss = arr.split("*")
    path = ss[0];
    row = ss[1];
    col = ss[2];
    autostart = ss[3];
    ran = rand();
    var string;
    string="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+row+"' height='"+col+"'><param name='CONTROLS' value='ImageWindow'><param name='CONSOLE' value='Clip'><param name='AUTOSTART' value='"+ autostart +"'><param name=src value="+path+"></object><br><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'  width="+row+" height=56><param name='CONTROLS' value='ControlPanel,StatusBar'><param name='CONSOLE' value='Clip'></object>";
    AsaiIFrame.document.body.innerHTML+=string;
    }else AsaiIFrame.focus();}//emot
    function Asai_foremot()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/emot.htm", "", "dialogWidth:760px; dialogHeight:380px; status:0; help:0");
    if (arr != null)
    {Asai_InsertSymbol(arr);
    AsaiIFrame.focus();}
    else AsaiIFrame.focus();}
      

  2.   

    //查找替换
    function Asai_replace()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/replace.htm", "", "dialogWidth:333px; dialogHeight:222px; status:0; help:0");
    if (arr != null){
    var ss;
    ss = arr.split("*")
    a = ss[0];
    b = ss[1];
    i = ss[2];
    con = AsaiIFrame.document.body.innerHTML;
    if (i == 1)
    {con = Asai_rCode(con,a,b,true);
    }else{
    con = Asai_rCode(con,a,b);
    }AsaiIFrame.document.body.innerHTML = con;
    }else AsaiIFrame.focus();}//插入图片
    function Asai_Img()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/img.htm", window, "dialogWidth:366px; dialogHeight:380px; status:0; help:0");
    if (arr != null){
    var ss;
    ss=arr.split("*")
    a=ss[0];//地址.
    b=ss[1];//alt.
    c=ss[2];//提示
    d=ss[3];//效果.
    e=ss[4];//位置.
    f=ss[5];//长.
    g=ss[6];//宽.
    h=ss[7];//上下.
    i=ss[8];//左右.
    j=ss[9];//边框.
    k=ss[10];//颜色.
    var strpic;
    strpic=""
    if(e.value!="")strpic=strpic+"<p align="+e+">"
    strpic=strpic+"<img src="+a+""
    strpic=strpic+" style='"
    if(h.value!='')strpic=strpic+"padding-top:"+h+"px;padding-bottom:"+h+"px;"
    if(i.value!='')strpic=strpic+"padding-top:"+i+"px;padding-bottom:"+i+"px;"
    if(j.value!='')strpic=strpic+"border:"+j+"px "+k+" solid;"
    if(f.value!='')strpic=strpic+"width:"+f+"px;"
    if(g.value!='')strpic=strpic+"height:"+g+"px;"
    if(d.value!='')strpic=strpic+""+d+";"
    strpic=strpic+"'"
    if(b.value!="")strpic=strpic+" alt='"+b+"' "
    strpic=strpic+">"
    if(c.value!="")strpic=strpic+"<br>"+c+""
    if(e.value!="")strpic=strpic+"</p>"AsaiIFrame.document.body.innerHTML+=strpic;
    }AsaiIFrame.focus();}//插入特殊符号
    function insertSpecialChar()
    {var arr = showModalDialog(""+Sm+""+Se+"HtmPop/specialchar.htm", "","dialogWidth:555px; dialogHeight:432px; status:0; help:0");
    if (arr != null) Asai_InsertSymbol(arr);
    AsaiIFrame.focus() ;}//插入表格
    function Asai_fortable()
    {if (!Asai_validateMode()) return;
    AsaiIFrame.focus();
    var arr = showModalDialog(""+Sm+""+Se+"HtmPop/table.htm", window, "dialogWidth:333px; dialogHeight:380px; status:0; help:0;scroll:no;");
    if (arr){AsaiIFrame.document.body.innerHTML+=arr;}
    AsaiIFrame.focus();}//修改表格、插入列+行等 begin
    function Asai_InsertRow()
    {editor = AsaiIFrame;
    objReference = Asai_GetRangeReference(editor);
    objReference = Asai_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
    switch(objReference.tagName)
    {
    case 'TABLE' :
    var newTable = objReference.cloneNode(true);
    var newRow = newTable.insertRow();
    for(x = 0; x<newTable.rows[0].cells.length; x++)
    {
    var newCell = newRow.insertCell();
    }
    objReference.outerHTML = newTable.outerHTML;
    break;
    case 'TBODY' :
    var newTable = objReference.cloneNode(true);
    var newRow = newTable.insertRow();
    for(x = 0; x<newTable.rows[0].cells.length; x++)
    {
    var newCell = newRow.insertCell();
    }
    objReference.outerHTML=newTable.outerHTML;
    break;
    case 'TR' :
    var rowIndex = objReference.rowIndex;
    var parentTable = objReference.parentElement.parentElement;
    var newTable = parentTable.cloneNode(true);
    var newRow = newTable.insertRow(rowIndex+1);
    for(x = 0; x< newTable.rows[0].cells.length; x++)
    {
    var newCell = newRow.insertCell();
    }
    parentTable.outerHTML = newTable.outerHTML;
    break;
    case 'TD' :
    var parentRow = objReference.parentElement;
    var rowIndex = parentRow.rowIndex;
    var cellIndex = objReference.cellIndex;
    var parentTable = objReference.parentElement.parentElement.parentElement;
    var newTable = parentTable.cloneNode(true);
    var newRow = newTable.insertRow(rowIndex+1);
    for(x = 0; x< newTable.rows[0].cells.length; x++)
    {
    var newCell = newRow.insertCell();
    if (x == cellIndex)newCell.id='ura';
    }
    parentTable.outerHTML = newTable.outerHTML;
    var r = editor.document.body.createTextRange();
    var item = editor.document.getElementById('ura');
    item.id = '';
    r.moveToElementText(item);
    r.moveStart('character',r.text.length);
    r.select();
    break;
    default :
    return;
    }
    }
    function Asai_DeleteRow()
    {
    editor=AsaiIFrame;
    objReference=Asai_GetRangeReference(editor);
    objReference=Asai_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
    switch(objReference.tagName)
    {
    case 'TR' :var rowIndex = objReference.rowIndex;
    var parentTable=objReference.parentElement.parentElement;
    parentTable.deleteRow(rowIndex);
    break;
    case 'TD' :var cellIndex=objReference.cellIndex;
    var parentRow=objReference.parentElement;
    var rowIndex = parentRow.rowIndex;
    var parentTable=objReference.parentElement.parentElement.parentElement;
    parentTable.deleteRow(rowIndex);
    if (rowIndex>=parentTable.rows.length)
    {
    rowIndex=parentTable.rows.length-1;
    }
    if (rowIndex>=0)
    {
    var r = editor.document.body.createTextRange();
    r.moveToElementText(parentTable.rows[rowIndex].cells[cellIndex]);
    r.moveStart('character',r.text.length);
    r.select();
    }
    else
    {
    parentTable.removeNode(true);
    }
    break;
    default :return;
    }
    }function Asai_InsertColumn()
    {
    editor = AsaiIFrame;
    objReference= Asai_GetRangeReference(editor);
    objReference=Asai_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
    switch(objReference.tagName)
    {
    case 'TABLE' :
    var newTable=objReference.cloneNode(true);
    for(x=0; x<newTable.rows.length; x++)
    {
    var newCell = newTable.rows[x].insertCell();
    }
    newCell.focus();
    objReference.outerHTML=newTable.outerHTML;
    break;
    case 'TBODY' :
    var newTable=objReference.cloneNode(true);
    for(x=0; x<newTable.rows.length; x++)
    {
    var newCell = newTable.rows[x].insertCell();
    }
    objReference.outerHTML=newTable.outerHTML;
    break;
    case 'TR' :
    objReference=objReference.parentElement.parentElement;
    var newTable=objReference.cloneNode(true);
    for(x=0; x<newTable.rows.length; x++)
    {
    var newCell = newTable.rows[x].insertCell();
    }
    objReference.outerHTML=newTable.outerHTML;
    break;
    case 'TD' :
    var cellIndex = objReference.cellIndex;
    var rowIndex=objReference.parentElement.rowIndex;
    var parentTable=objReference.parentElement.parentElement.parentElement;
    var newTable=parentTable.cloneNode(true);
    for(x=0; x<newTable.rows.length; x++)
    {
    var newCell = newTable.rows[x].insertCell(cellIndex+1);
    if (x==rowIndex)newCell.id='ura';
    }
    parentTable.outerHTML=newTable.outerHTML;
    var r = editor.document.body.createTextRange();
    var item=editor.document.getElementById('ura');
    item.id='';
    r.moveToElementText(item);
    r.moveStart('character',r.text.length);
    r.select();
    break;
    default :
    return;
    }
    }
      

  3.   

    function Asai_DeleteColumn()
    {
    editor = AsaiIFrame;
    objReference=Asai_GetRangeReference(editor);
    objReference=Asai_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
    switch(objReference.tagName)
    {

    case 'TD' :var rowIndex=objReference.parentElement.rowIndex;
    var cellIndex = objReference.cellIndex;
    var parentTable=objReference.parentElement.parentElement.parentElement;
    var newTable=parentTable.cloneNode(true);
    if (newTable.rows[0].cells.length==1)
    {
    parentTable.removeNode(true);
    return;
    }
    for(x=0; x<newTable.rows.length; x++)
    {
    if (newTable.rows[x].cells[cellIndex]=='[object]')
    {
    newTable.rows[x].deleteCell(cellIndex);
    }
    }
    if (cellIndex>=newTable.rows[0].cells.length)
    {
    cellIndex=newTable.rows[0].cells.length-1;
    }
    if (cellIndex>=0)  newTable.rows[rowIndex].cells[cellIndex].id='ura';
    parentTable.outerHTML=newTable.outerHTML;
    if (cellIndex>=0){
    var r = editor.document.body.createTextRange();
    var item=editor.document.getElementById('ura');
    item.id='';
    r.moveToElementText(item);
    r.moveStart('character',r.text.length);
    r.select();
    }
    break;
    default :return;
    }
    }
    //修改表格、插入列+行等 end
    //直接用到的过程 begin// 插入换行
    function Asai_InBR(){
    if (!Asai_validateMode()) return;
    Asai_InsertSymbol('<BR>');
    }//清空
    function ClearReset()
    {AsaiIFrame.document.body.innerHTML='';
    AsaiIFrame.focus();}//增加、减小编辑器大小
    function Asai_Size(num)
    {var obj=document.getElementById("Asai_Composition");
    if (parseInt(obj.offsetHeight)+num>=100){
    obj.height = (parseInt(obj.offsetHeight) + num);}
    if (num>0){
    obj.width="100%";}}//编辑器的设计、预览、源码模式切换
    function Asai_setMode(n)
    {Asai_setStyle();
    var cont;
    var arsty=document.getElementById("Ar");
    switch (n){
    case 1:
    arsty.style.display="";
    if (document.getElementById("Asai_TabHtml").className=="Aba"){
    if (Asai_bIsIE5){
    cont=AsaiIFrame.document.body.innerText;
    cont=Asai_correctUrl(cont);
    if (Asai_filterScript)
    cont=Asai_FilterScript(cont);
    AsaiIFrame.document.body.innerHTML="<a> </a>"+cont;
    }else{
    var html = AsaiIFrame.document.body.ownerDocument.createRange();
    html.selectNodeContents(AsaiIFrame.document.body);
    AsaiIFrame.document.body.innerHTML = html.toString();
    }}break;
    case 2:
    arsty.style.display="none";
    Asai_cleanHtml();
    cont=AsaiIFrame.document.body.innerHTML;
    cont=Asai_rCode(AsaiIFrame.document.body.innerHTML,"<a> </a>","");
    cont=Asai_correctUrl(cont);
    if (Asai_filterScript){cont=Asai_FilterScript(cont);}
    if (Asai_bIsIE5){
    AsaiIFrame.document.body.innerText=cont;
    }else{
    var html=document.createTextNode(cont);
    AsaiIFrame.document.body.innerHTML = "";
    AsaiIFrame.document.body.appendChild(html);
    }break;}
    Asai_setTab(n);
    Asai_bTextMode=n}//选择后的样式变化
    function Asai_setTab(n)
    {var mhtml=document.getElementById("Asai_TabHtml");
    var mdesign=document.getElementById("Asai_TabDesign");
    if (n==1)
    {mhtml.className="Ab";
    mdesign.className="Aba";}
    else if (n==2)
    {mhtml.className="Aba";
    mdesign.className="Ab";}
    }//基本的格式化文本命令
    function FormatText(command, option)
    {var codewrite
    if (Asai_bIsIE5){
    if (option=="removeFormat"){
    command=option;
    option=null;}
    AsaiIFrame.focus();
    AsaiIFrame.document.execCommand(command, false, option);
    Asai_pureText = false;
    AsaiIFrame.focus();
    }else{
    if ((command == 'forecolor') || (command == 'backcolor')) {
    parent.command = command;
    buttonElement = document.getElementById(command);
    AsaiIFrame.focus();
    document.getElementById("colourPalette").style.left = getOffsetLeft(buttonElement) + "px";
    document.getElementById("colourPalette").style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
    if (document.getElementById("colourPalette").style.visibility=="hidden")
    {document.getElementById("colourPalette").style.visibility="visible";
    }else {
    document.getElementById("colourPalette").style.visibility="hidden";}
    var sel = AsaiIFrame.document.selection; 
    if (sel != null){Asai_colour = sel.createRange();}
    }else{
    AsaiIFrame.focus();
    AsaiIFrame.document.execCommand(command, false, option);
    Asai_pureText = false;
    AsaiIFrame.focus();}}}//清理编辑器内代码
    function Asai_CleanCode()
    {var editor=AsaiIFrame;
    editor.focus();
    if (Asai_bIsIE5){
    var body = editor.document.body;
    for (var index = 0; index < body.all.length; index++) {
    tag = body.all[index];
    tag.removeAttribute("className","",0);
    tag.removeAttribute("style","",0);}
    var html = editor.document.body.innerHTML;
    html = html.replace(/<BR><BR><BR>/g,"<BR><BR>");
    html = html.replace(/<P>&nbsp;<\/P>/g,"");
    html = html.replace(/<P><\/P>/g,"<BR>");
    html = html.replace(/\<p>/gi,"[$p]");
    html = html.replace(/\<\/p>/gi,"[$\/p]");
    html = html.replace(/\<br>/gi,"[$br]");
    html = html.replace(/\<[^>]*>/g,"");
    html = html.replace(/ /g,"");
    html = html.replace(/&nbsp;/g,"");
    html = html.replace(/\[\$p\]/gi,"<p>");
    html = html.replace(/\[\$\/p\]/gi,"<\/p>");
    html = html.replace(/\[\$br\]/gi,"<br>");
    editor.document.body.innerHTML = html;
    }else{
    var html = AsaiIFrame.document.body.ownerDocument.createRange();
    html.selectNodeContents(AsaiIFrame.document.body);
    AsaiIFrame.document.body.innerHTML = html.toString();}}function Asai_correctUrl(cont)
    {var regExp;
    var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
    cont=Asai_rCode(cont,location.href+"#","#");
    cont=Asai_rCode(cont,url,"");
    cont=Asai_rCode(cont,"<a> </a>","");
    return cont;}function Asai_cleanHtml()
    {if (Asai_bIsIE5){
    var fonts = AsaiIFrame.document.body.all.tags("FONT");
    }else{
    var fonts = AsaiIFrame.document.all("FONT");}
    var curr;
    for (var i = fonts.length - 1; i >= 0; i--) {
    curr = fonts[i];
    if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;}}function Asai_InsertSymbol(str1)
    {AsaiIFrame.focus();
    if (Asai_bIsIE5) Asai_selectRange();
    Asai_edit.pasteHTML(str1);}function Asai_selectRange(){
    Asai_selection =AsaiIFrame.document.selection;
    Asai_edit=Asai_selection.createRange();
    Asai_RangeType =Asai_selection.type;}
      

  4.   

    换马甲再贴,不是灌水哈//编辑器里面插入内容用
    function Asai_specialtype(Mark1, Mark2){
    var strHTML;
    if (Asai_bIsIE5){
    Asai_selectRange();
    if (Asai_RangeType == "Text"){
    if (Mark2==null)
    {strHTML = "<" + Mark1 + ">" + Asai_edit.htmlText + "</" + Mark1 + ">"; 
    }else{
    strHTML = Mark1 + Asai_edit.htmlText +  Mark2; 
    }
    Asai_edit.pasteHTML(strHTML);
    AsaiIFrame.focus();
    Asai_edit.select();
    }else{window.alert("请选择相应内容!")}
    }
    else{
    if (Mark2==null)
    {strHTML="<" + Mark1 + ">" + AsaiIFrame.document.body.innerHTML + "</" + Mark1 + ">"; 
    }else{
    strHTML = Mark1 + AsaiIFrame.document.body.innerHTML +  Mark2; 
    }
    AsaiIFrame.document.body.innerHTML=strHTML
    AsaiIFrame.focus();
    }}function Asai_getText()
    {if (Asai_bTextMode==2)
    return AsaiIFrame.document.body.innerText;
    else
    {Asai_cleanHtml();
    return AsaiIFrame.document.body.innerHTML;
    }}function getOffsetTop(elm) {
    var mOffsetTop = elm.offsetTop;
    var mOffsetParent = elm.offsetParent;
    while(mOffsetParent){
    mOffsetTop += mOffsetParent.offsetTop;
    mOffsetParent = mOffsetParent.offsetParent;
    }return mOffsetTop;}function getOffsetLeft(elm) {
    var mOffsetLeft = elm.offsetLeft;
    var mOffsetParent = elm.offsetParent;
    while(mOffsetParent) {
    mOffsetLeft += mOffsetParent.offsetLeft;
    mOffsetParent = mOffsetParent.offsetParent;
    }return mOffsetLeft;}function rand() {
    return parseInt((1000)*Math.random()+1);}//检验连接地址是不是已经输入了
    function Asai_UserDialog(what)
    {if (!Asai_validateMode()) return;
    AsaiIFrame.focus();
    if (what == "CreateLink") {
    if (Asai_bIsNC){
    insertLink = prompt("请填写超级链接地址信息:", "http://");
    if ((insertLink != null) && (insertLink != "") && (insertLink != "undefined")) {
    AsaiIFrame.document.execCommand('CreateLink', false, insertLink);
    }else{
    AsaiIFrame.document.execCommand('unlink', false, null);
    }}
    else {AsaiIFrame.document.execCommand(what, true, null);}}
    if(what == "InsertImage"){
    imagePath = prompt('请填写图片链接地址信息:', 'http://');
    if ((imagePath != null) && (imagePath != "")) {
    AsaiIFrame.document.execCommand('InsertImage', false, imagePath);}
    AsaiIFrame.document.body.innerHTML = (AsaiIFrame.document.body.innerHTML).replace("src=\"file://","src=\"");
    }Asai_pureText = false;
    AsaiIFrame.focus();}function Asai_GetRangeReference(editor)
    {editor.focus();
    var objReference = null;
    var RangeType = editor.document.selection.type;
    var selectedRange = editor.document.selection.createRange();
    switch(RangeType)
    {case 'Control' :
    if (selectedRange.length > 0 ){
    objReference = selectedRange.item(0);}
    break;
    case 'None' :
    objReference = selectedRange.parentElement();
    break;
    case 'Text' :
    objReference = selectedRange.parentElement();
    break;}
    return objReference}function Asai_CheckTag(item,tagName)
    {if (item.tagName.search(tagName)!= -1)
    {return item;}
    if (item.tagName == 'BODY'){
    return false;}
    item=item.parentElement;
    return Asai_CheckTag(item,tagName);}//自动排版
    function AutoPB()
    {window.alert("您不能这样做!")}
    //阿赛超级自动排版
    function AsaiPB()
    {window.alert("您不能这样做!")}
    function Asai_rCode(s,a,b,i)
    {a = a.replace("?","\\?");
    if (i==null){
    var r = new RegExp(a,"gi");
    }else if (i) {
    var r = new RegExp(a,"g");
    }else{
    var r = new RegExp(a,"gi");}
    return s.replace(r,b); }//编辑器内容check和提交代码 beging
    //判断提交时候的状态
    function Asai_validateMode()
    {
    if (Asai_bTextMode!=2) return true;
    alert("请取消查看[源码]状态,调至[设计]状态再行提交,谢谢!");
    AsaiIFrame.focus();
    return false;}//编辑器内容预览
    function Asai_View()
    {if (Asai_bTextMode==2) {
    cont=AsaiIFrame.document.body.innerText;
    } else {
    cont=AsaiIFrame.document.body.innerHTML;}
    cont=Asai_correctUrl(cont);
    bodyTag="<html><head></head><BODY style='font-size:12px;'>";
    if (Asai_filterScript)
    cont=Asai_FilterScript(cont);
    preWin=window.open('','','');
    preWin.document.open();
    preWin.document.write(bodyTag);
    preWin.document.write(cont);
    preWin.document.close();
    preWin.document.title="阿赛提示:您正在预览编辑器中的内容......";
    preWin.document.charset=Asai_charset;
    }
    //编辑器区域整体样式表现
    function Asai_InitDocument(hiddenid, charset)
    {
    if (charset!=null)
    Asai_charset=charset;
    var Asai_bodyTag="</head><BODY bgcolor=\"#ffffff\" style='font-size:9pt;'>";
    if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){
    AsaiIFrame.document.designMode="On"
    }
    AsaiIFrame.document.open();
    AsaiIFrame.document.write ('<html><head>');
    if (Asai_bIsIE5){
    }
    AsaiIFrame.document.write(Asai_bodyTag);
    AsaiIFrame.document.write("</body>");
    AsaiIFrame.document.write("</html>");
    AsaiIFrame.document.close();
    AsaiIFrame.document.body.contentEditable = "True";
    AsaiIFrame.document.charset=Asai_charset;
    Asai_bLoad=true;
    Asai_setStyle();
    }//编辑器区域滚动条样式
    function Asai_setStyle()
    {var bs = AsaiIFrame.document.body.style;
    if (Asai_bTextMode==2){
    //bs.fontFamily="Verdana";
    bs.fontSize="12px";
    }else{
    //bs.fontFamily="Verdana";
    bs.fontSize="12px";}
    bs.scrollbarShadowColor= '#'+sy+'';//立体滚动条阴影的颜色
    bs.scrollbar3dLightColor= '#'+by+'';//滚动条亮边的颜色
    bs.scrollbarArrowColor= '#'+sy+'';//上下按钮上三角箭头的颜色
    bs.scrollbarBaseColor= '#'+by+'';//滚动条的基本颜色
    bs.scrollbarDarkShadowColor= '#'+by+'';//滚动条强阴影的颜色
    bs.scrollbarFaceColor= '#'+by+'';//滚动条凸出部分的颜色
    bs.scrollbarHighlightColor= '#'+sy+'';//滚动条空白部分的颜色
    bs.scrollbarTrackColor= '#'+qy+'';//滚动条的背景颜色
    bs.border='0';}function submits(){
    var html;
    html=Asai_getText();
    html=Asai_rCode(html,"<a> </a>","");
    document.getElementById(""+an+"").value=html;}function load_edit(){
    content=document.getElementById(""+an+"").value;
    AsaiIFrame.document.body.innerHTML=content;
    document.getElementById(""+an+"").value="";}function load_content(){
    if (!Asai_validateMode()){return false;}
    document.getElementById(""+an+"").value=AsaiIFrame.document.body.innerHTML;
    if(AsaiIFrame.document.body.innerHTML==""){
    alert("内容不能为空");
    AsaiIFrame.document.body.focus();
    return false;}
    return true;}//去掉所有HTML符号检验是否为空值
    function Asai_ChekEmptyCode(html)
    {html = html.replace(/\<[^>]*>/g,"");
    html = html.replace(/&nbsp;/gi, "");
    html = html.replace(/o:/gi, "");
    html = html.replace(/\s/gi, "");
    return html;}function getHTML()
    {var html;
    if (!Asai_bTextMode) 
    {html = AsaiIFrame.document.body.innerHTML}
    else
    {html = AsaiIFrame.document.body.innerText}
    return html;
    }
      

  5.   

    最后一段//编辑器内容check和提交代码 end
    var ONMT='class="as2" onMouseOver="this.className=\'as1\';" onMouseOut="this.className=\'as2\';"'
    document.writeln('<div ID="Ar" style="width:100%;">');
    document.writeln('<div id="asaifontselect"><select ID="Asai_formatSelect" onChange="Asai_FontHBsty(this[this.selectedIndex].value)"><option>段落格式</option><option value="0">普通格式</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><option value="8">段落</option><option value="9">定义</option><option value="10">术语定义</option><option value="11">目录列表</option><option value="12">菜单列表</option><option value="13">已编格式</option><option value="21">模糊文字</option><option value="22">文字加亮</option><option value="23">阴影文字</option><option value="24">图底文字</option><option value="25">文字微缩</option><option value="26">文字左倒</option><option value="27">古书文字</option><option value="28">文字加亮</option><option value="29">光晕</option><option value="30">模糊</option><option value="31">阴影</option><option value="32">透明</option><option value="33">立体</option><option value="91">设为代码</option><option value="92">设为引用</option><option value="93">设为隐藏</option></select><select language="javascript" id="FontName" onChange="FormatText (\'FontName\',this[this.selectedIndex].value);"><option selected>字体</option><option value="宋体">宋体</option><option value="黑体">黑体</option><option value="楷体_GB2312">楷体</option><option value="仿宋_GB2312">仿宋</option><option value="隶书">隶书</option><option value="幼圆">幼圆</option><option value="新宋体">新宋体</option><option value="细明体">细明体</option><option value="Arial">Arial</option><option value="Arial Black">Arial Black</option><option value="Arial Narrow">Arial Narrow</option><option value="Bradley Hand ITC">Bradley Hand ITC</option><option value="Brush Scrip MT">Brush Script MT</option><option value="Century Gothic">Century Gothic</option><option value="Comic Sans MS">Comic Sans MS</option><option value="Courier">Courier</option><option value="Courier New">Courier New</option><option value="MS Sans Serif">MS Sans Serif</option><option value="Script">Script</option><option value="System">System</option><option value="Times New Roman">Times New Roman</option><option value="Viner Hand ITC">Viner Hand ITC</option><option value="Verdana">Verdana</option><option value="Wide Latin">Wide Latin</option><option value="Wingdings">Wingdings</option></select><select language="javascript" id="FontSize" onChange="Asai_FontHsize(this[this.selectedIndex].value);"><option selected>字号</option><option value="7">一号</option><option value="6">二号</option><option value="5">三号</option><option value="4">四号</option><option value="3">五号</option><option value="2">六号</option><option value="1">七号</option>');
    for(i=1;i<29;i++)document.write("<option value="+i+">"+i+" pt\n")
    document.write('<option value=30>30 pt</option><option value=35>35 pt</option><option value=40>40 pt</option><option value=45>45 pt</option><option value=50>50 pt</option><option value=60>60 pt</option><option value=70>70 pt</option><option value=85>85 pt</option><option value=100>100 pt</option><option value=120>120 pt</option><option value=150>150 pt</option><option value=200>200 pt</option><option value=250>250 pt</option><option value=300>300 pt</option><option value=500>500 pt</option><option value=900>900 pt</option><option value=2000>2000 pt</option></select></div>');
    document.writeln('<img '+ONMT+' alt="加粗" onClick="FormatText(\'bold\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Bold.gif"><img '+ONMT+' alt="斜体" onClick="FormatText(\'italic\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Italic.gif"><img '+ONMT+' alt="下划线" onClick="FormatText(\'underline\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Underline.gif"><img '+ONMT+' alt="上标" onClick="FormatText(\'superscript\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/ShangBiao.gif"><img '+ONMT+' alt="下标" onClick="FormatText(\'subscript\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/XiaBiao.gif"><img '+ONMT+' alt="删除线" onClick="FormatText(\'strikethrough\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Through_Line.gif"><img '+ONMT+' id="forecolor" alt="字体颜色" onClick="Asai_foreColor();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Font_Color.gif"><img '+ONMT+' id="backcolor" alt="字体背景颜色" onClick="Asai_backColor();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Font_BgColor.gif"><img '+ONMT+' alt="左对齐" onClick="FormatText(\'justifyleft\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Left.gif"><img '+ONMT+' alt="居中" onClick="FormatText(\'justifycenter\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Center.gif"><img '+ONMT+' alt="右对齐" onClick="FormatText(\'justifyright\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Right.gif"><img '+ONMT+' alt="编号" onClick="FormatText(\'insertorderedlist\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/List.gif"><img '+ONMT+' alt="项目符号" onClick="FormatText(\'insertunorderedlist\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/List_Tu.gif"><img '+ONMT+' alt="减少缩进量" onClick="FormatText(\'outdent\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Outdent.gif"><img '+ONMT+' alt="增加缩进量" onClick="FormatText(\'indent\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Indent.gif"><img '+ONMT+' alt="替换" onClick="Asai_replace();" src="'+Sm+''+Se+'SysImg/TiHuan.gif"><img '+ONMT+' alt="撤消" onClick="FormatText(\'undo\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Undo.gif"><img '+ONMT+' alt="恢复" onClick="FormatText(\'redo\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Redo.gif"><img '+ONMT+' alt="插入水平线" onClick="FormatText(\'InsertHorizontalRule\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Line.gif"><img '+ONMT+' alt="插入换行符" onClick="Asai_InBR();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/br.gif"><img '+ONMT+' id="selectall" alt="全选" onClick="FormatText(\'selectAll\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/SelectAll.gif"><img '+ONMT+' alt="剪切" onClick="FormatText(\'cut\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Cut.gif"><img '+ONMT+' alt="复制" onClick="FormatText(\'copy\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Copy.gif"><img '+ONMT+' alt="常规粘贴" onClick="FormatText(\'paste\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/NianTie.gif"><img '+ONMT+' alt="纯文本粘贴" onClick="PasteText();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/pastetext.gif"><img '+ONMT+' alt="取消文字样式" onClick="FormatText(\'RemoveFormat\', \'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Format.gif"><img '+ONMT+' alt="清理HTML代码" onClick="Asai_CleanCode();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Qing.gif"><img '+ONMT+' alt="自动排版" onClick="AutoPB();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/AutoPB.gif"><img '+ONMT+' alt="阿赛排版:复制外网文章后,单击一下,即可自动完成内容排版。" onClick="AsaiPB();" src="'+Sm+''+Se+'SysImg/AsaiPB.gif"><img '+ONMT+' alt="插入超级链接" onClick="Asai_UserDialog(\'CreateLink\',\'\',\'\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Link.gif"><img '+ONMT+' alt="去掉超级链接" onClick="FormatText(\'UnLink\');ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/UnLink.gif"><img '+ONMT+' alt="插入表格" onClick="Asai_fortable();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Table.gif"><img '+ONMT+' alt="插入行" onClick="Asai_InsertRow();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Hang_Add.gif"><img '+ONMT+' alt="删除行" onClick="Asai_DeleteRow();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Hang_Del.gif"><img '+ONMT+' alt="插入列" onClick="Asai_InsertColumn();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Lie_Add.gif"><img '+ONMT+' alt="删除列" onClick="Asai_DeleteColumn();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Lie_Del.gif"><img '+ONMT+' id="zifu" alt="插入特殊符号" onClick="insertSpecialChar();" src="'+Sm+''+Se+'SysImg/ZiFu.gif"><img '+ONMT+' alt="插入图片" onClick="Asai_Img();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Img.gif"><img '+ONMT+' alt="插入Flash" onClick="Asai_forswf();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Flash.gif"><img '+ONMT+' alt="插入Windows Media" onClick="Asai_forwmv();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Media.gif"><img '+ONMT+' alt="插入Real Media" onClick="Asai_forrm();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/Rm.gif"><img '+ONMT+' alt="插入大表情" onClick="Asai_foremot()" src="'+Sm+''+Se+'SysImg/Emot.gif"><img '+ONMT+' alt="插入小表情" onClick="Asai_qq()" src="'+Sm+''+Se+'SysImg/qq.gif"><img '+ONMT+' alt="关于阿赛HTML在线编辑器" onClick="Asai_about();ondrag=\'return false;\'" src="'+Sm+''+Se+'SysImg/about.gif"></div>');
    document.writeln('<div id=Ac style="width:100%;"><iframe ID="Asai_Composition" MARGINHEIGHT="2" MARGINWIDTH="2" width="100%" height="200" name="I1" style="border:0px"></iframe>');
    document.writeln('</div>');
    document.writeln('<div id=At style="width:100%;">');
    document.writeln('<div title="所见即所得编辑模式" class="Aba" id="Asai_TabDesign" onClick="if (Asai_bTextMode!=1) {Asai_setMode(1);}">设&nbsp;计<\/div><div title="在新窗口查看预览效果" class="Ab" id="Asai_TabView" onClick="Asai_View();">预&nbsp;览<\/div><div title="源码编辑模式" class="Ab" id="Asai_TabHtml" onClick="if (Asai_bTextMode!=2) {Asai_setMode(2);}">源&nbsp;码<\/div><div title="清空编辑器内的内容" class="Ab" onClick="ClearReset();">清&nbsp;空<\/div><div title="增大编辑高度" class="Aj" onClick="javascript:Asai_Size(100)">╋<\/div><div title="减小编辑高度" class="Aj" onClick="javascript:Asai_Size(-100)">━<\/div><\/div>');
    var Asai_bIsIE5=document.all;
    var canusehtml='1';
    var PostType=1;
    if (Asai_bIsIE5){
    var AsaiIFrame=frames["Asai_Composition"];}
    else{
    var AsaiIFrame=document.getElementById("Asai_Composition").contentWindow;
    var Asai_bIsNC=true;
    }
    if (Asai_bLoad==false)
    {Asai_InitDocument("Body",Asai_charset);}