麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
一编辑器,一些代码看不懂,望高手指点
悬赏分:20 - 2007年08月13日

那是关于图片的插入: 。 edtior.js的代码如下: var bodyID,htmlableID; var WBTB_yToolbars = new Array(); var WBTB_YInitialized = false; var WBTB_filterScript = false; var WBTB_charset="UTF-8"; function document.onreadystatechange() { if (WBTB_YInitialized) return; WBTB_YInitialized = true; var i, s, curr; for (i=0; i; if (curr.className == "yToolbar") { WBTB_InitTB(curr); WBTB_yToolbars[WBTB_yToolbars.length] = curr; } } } function WBTB_InitBtn(btn) { btn.onmouseover = WBTB_BtnMouseOver; btn.onmouseout = WBTB_BtnMouseOut; btn.onmousedown = WBTB_BtnMouseDown; btn.onmouseup = WBTB_BtnMouseUp; btn.ondragstart = WBTB_YCancelEvent; btn.onselectstart = WBTB_YCancelEvent; btn.onselect = WBTB_YCancelEvent; btn.YUSERONCLICK = btn.onclick; btn.onclick = WBTB_YCancelEvent; btn.YINITIALIZED = true; return true; } function WBTB_InitTB(y) { y.TBWidth = 0; if (!WBTB_PopulateTB(y)) return false; y.style.posWidth = y.TBWidth; return true; } function WBTB_YCancelEvent() { event.returnValue=false; event.cancelBubble=true; return false; } function WBTB_BtnMouseOver() { if (event.srcElement.tagName != "IMG") return false; var image = event.srcElement; var element = image.parentElement; if (image.className == "WBTB_Ico") element.className = "WBTB_BtnMouseOverUp"; else if (image.className == "WBTB_IcoDown") element.className = "WBTB_BtnMouseOverDown"; event.cancelBubble = true; } function WBTB_BtnMouseOut() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; yRaisedElement = null; element.className = "WBTB_Btn"; image.className = "WBTB_Ico"; event.cancelBubble = true; } function WBTB_BtnMouseDown() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; event.returnValue=false; return false; } var image = event.srcElement; var element = image.parentElement; element.className = "WBTB_BtnMouseOverDown"; image.className = "WBTB_IcoDown"; event.cancelBubble = true; event.returnValue=false; return false; } function WBTB_BtnMouseUp() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()"); element.className = "WBTB_BtnMouseOverUp"; image.className = "WBTB_Ico"; event.cancelBubble = true; return false; } function WBTB_PopulateTB(y) { var i, elements, element; elements = y.children; for (i=0; i; if (element.tagName== "SCRIPT" || element.tagName == "!") continue; switch (element.className) { case "WBTB_Btn": if (element.YINITIALIZED == null) { if (! WBTB_InitBtn(element)) return false; } element.style.posLeft = y.TBWidth; y.TBWidth += element.offsetWidth + 1; break; case "WBTB_TBGen": element.style.posLeft = y.TBWidth; y.TBWidth += element.offsetWidth + 1; break; //default: // return false; } } y.TBWidth += 1; return true; } function WBTB_DebugObject(obj) { var msg = ""; for (var i in TB) { ans=prompt(i+"="+TB+"\n"); if (! ans) break; } } function WBTB_validateMode() { if (!WBTB_bTextMode) return true; alert("ÇëÈ¡Ïû¡°²é¿´HTMLÔ´´úÂ롱ѡÏîÔÙʹÓÃϵͳ±à¼­¹¦ÄÜ»òÕßÌá½»!"); WBTB_Composition.focus(); return false; } function WBTB_format1(what,opt) { if (opt=="removeFormat") { what=opt; opt=null; } WBTB_Composition.focus(); if (opt==null) { WBTB_Composition.document.execCommand(what); }else{ WBTB_Composition.document.execCommand(what,"",opt); } WBTB_pureText = false; WBTB_Composition.focus(); } function WBTB_format(what,opt) { if (!WBTB_validateMode()) return; WBTB_format1(what,opt); } function WBTB_setMode() { WBTB_bTextMode=!WBTB_bTextMode; WBTB_setTab(); var cont; if (WBTB_bTextMode) { document.all.WBTB_Toolbars.style.display='none'; WBTB_cleanHtml(); cont=WBTB_Composition.document.body.innerHTML; cont=WBTB_correctUrl(cont); if (WBTB_filterScript) cont=WBTB_FilterScript(cont); WBTB_Composition.document.body.innerText=cont; } else { document.all.WBTB_Toolbars.style.display=''; cont=WBTB_Composition.document.body.innerText; cont=WBTB_correctUrl(cont); if (WBTB_filterScript) cont=WBTB_FilterScript(cont); WBTB_Composition.document.body.innerHTML=cont; } WBTB_setStyle(); WBTB_Composition.focus(); } function WBTB_setStyle() { bs = WBTB_Composition.document.body.runtimeStyle; //¸ù¾ÝmodeÉèÖÃiframeÑùʽ±í if (WBTB_bTextMode) { bs.fontFamily="Arial"; bs.fontSize="10pt"; }else{ bs.fontFamily="Arial"; bs.fontSize="10.5pt"; } bs.scrollbar3dLightColor= '#D4D0C8'; bs.scrollbarArrowColor= '#000000'; bs.scrollbarBaseColor= '#D4D0C8'; bs.scrollbarDarkShadowColor= '#D4D0C8'; bs.scrollbarFaceColor= '#D4D0C8'; bs.scrollbarHighlightColor= '#808080'; bs.scrollbarShadowColor= '#808080'; bs.scrollbarTrackColor= '#D4D0C8'; bs.border='0'; } function WBTB_setTab() { //htmlºÍdesign°´Å¥µÄÑùʽ¸ü¸Ä var mhtml=document.all.WBTB_TabHtml; var mdesign=document.all.WBTB_TabDesign; if (WBTB_bTextMode) { mhtml.className="WBTB_TabOn"; mdesign.className="WBTB_TabOff"; }else{ mhtml.className="WBTB_TabOff"; mdesign.className="WBTB_TabOn"; } } function WBTB_getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement; return start; } function WBTB_UserDialog(what) { if (!WBTB_validateMode()) return; WBTB_Composition.focus(); WBTB_Composition.document.execCommand(what, true); //È¥µôÌí¼ÓͼƬʱµÄsrc="file:// if(what=="InsertImage") { WBTB_Composition.document.body.innerHTML=(WBTB_Composition.document.body.innerHTML).replace("src=\"file://","src=\"pictext"); } WBTB_pureText = false; WBTB_Composition.focus(); } function WBTB_foreColor() { if (!WBTB_validateMode()) return; var arr = showModalDialog("wbTextBox/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0"); if (arr != null) WBTB_format('forecolor', arr); else WBTB_Composition.focus(); } function WBTB_backColor() { if (!WBTB_validateMode()) return; var arr = showModalDialog("wbTextBox/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0"); if (arr != null) WBTB_format('backcolor', arr); else WBTB_Composition.focus(); } function WBTB_fortable() { if (!WBTB_validateMode()) return; var arr = showModalDialog("wbTextBox/table.html", "", "dialogWidth:14.5em; dialogHeight:16.5em; status:0; help:0"); if (arr != null) { var ss; ss=arr.split("*") row=ss[0]; if (row=="") row=1; col=ss[1]; if (col=="") col=1; tbwidth=ss[2]; if (tbwidth=="") tbwidth=500; tbborder=ss[3]; if (tbborder=="") tbborder=1; celpadding=ss[4]; if (celpadding=="") celpadding=2; bdcolor=ss[5]; if (bdcolor=="") bdcolor="#CCCCCC"; bgcolor=ss[6]; if (bgcolor=="") bgcolor="#FFFFFF"; tbalign=ss[7]; if (tbalign=="") tbalign="center"; var string; string=""; for(i=1;i<=row;i++){ string=string+""; for(j=1;j<=col;j++){ string=string+""; } string=string+""; } string=string+"
 
"; content=WBTB_Composition.document.body.innerHTML; content=content+string; WBTB_Composition.document.body.innerHTML=content; } else WBTB_Composition.focus(); } function WBTB_forswf() { var arr = showModalDialog("wbTextBox/swf.htm", "", "dialogWidth:15em; dialogHeight:13em; status:0; help:0"); if (arr != null){ var ss; ss=arr.split("*") path=ss[0]; row=ss[1]; col=ss[2]; var string; string="

" content=WBTB_Composition.document.body.innerHTML; content=content+string; WBTB_Composition.document.body.innerHTML=content; } else WBTB_Composition.focus(); } function WBTB_forwmv() { var arr = showModalDialog("wbTextBox/wmv.htm", "", "dialogWidth:15.5em; dialogHeight:14em; status:0; help:0"); if (arr != null){ var ss; ss=arr.split("*") path=ss[0]; width=ss[1]; height=ss[2]; var string; //string=""; string=""; content=WBTB_Composition.document.body.innerHTML; content=content+string; WBTB_Composition.document.body.innerHTML=content; } else WBTB_Composition.focus(); } function WBTB_forrm() { var arr = showModalDialog("wbTextBox/rm.htm", "", "dialogWidth:15.5em; dialogHeight:14em; status:0; help:0"); if (arr != null) { var ss; ss=arr.split("*") path=ss[0]; row=ss[1]; col=ss[2]; var string; string="
"; content=WBTB_Composition.document.body.innerHTML; content=content+string; WBTB_Composition.document.body.innerHTML=content; } else WBTB_Composition.focus(); } function WBTB_InsertRow() { editor = WBTB_Composition; objReference=WBTB_GetRangeReference(editor); objReference=WBTB_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/'); switch(objReference.tagName) { case 'TABLE' : var newTable=objReference.cloneNode(true); var newRow= newTable.insertRow(); for(x=0; x=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 WBTB_InsertColumn() { editor = WBTB_Composition; objReference= WBTB_GetRangeReference(editor); objReference=WBTB_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/'); switch(objReference.tagName) { case 'TABLE' :// IF a table is selected, it adds a new column on the right hand side of the table. var newTable=objReference.cloneNode(true); for(x=0; x=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; } } function WBTB_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 WBTB_CheckTag(item,tagName) { if (item.tagName.search(tagName)!=-1) { return item; } if (item.tagName=='BODY') { return false; } item=item.parentElement; return WBTB_CheckTag(item,tagName); } function WBTB_code() { WBTB_specialtype("
","
"); } function WBTB_replace() { var arr = showModalDialog("wbTextBox/replace.html", "", "dialogWidth:16.5em; dialogHeight:13em; status:0; help:0"); if (arr != null){ var ss; ss=arr.split("*") a=ss[0]; b=ss[1]; i=ss[2]; con=WBTB_Composition.document.body.innerHTML; if (i==1) { con=WBTB_rCode(con,a,b,true); }else{ con=WBTB_rCode(con,a,b); } WBTB_Composition.document.body.innerHTML=con; } else WBTB_Composition.focus(); } function WBTB_CleanCode() { editor=WBTB_Composition; editor.focus(); // 0bject based cleaning var body = editor.document.body; for (var index = 0; index < body.all.length; index++) { tag = body.all[index]; //if (tag.Attribute["className"].indexOf("mso") > -1) tag.removeAttribute("className","",0); tag.removeAttribute("style","",0); } // Regex based cleaning var html = editor.document.body.innerHTML; html = html.replace(/ <\/o:p>/gi, ""); html = html.replace(/o:/gi, ""); //html = html.replace(/]*>/gi, ""); // Final clean up of empty tags html = html.replace(/]*>\s*<\/font>/gi, ""); html = html.replace(/\s*<\/span>/gi, ""); editor.document.body.innerHTML = html; } function WBTB_FilterScript(content) { content = WBTB_rCode(content, 'javascript:', 'javascript :'); //var RegExp = /]*>(.|\n)*<\/script>/ig; //content = content.replace(RegExp, ""); var RegExp = /]*>/ig; content = content.replace(RegExp, ""); return content; } function WBTB_cleanHtml() { var fonts = WBTB_Composition.document.body.all.tags("FONT"); var curr; for (var i = fonts.length - 1; i >= 0; i--) { curr = fonts; if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML; } } function WBTB_getPureHtml() { var str = ""; //var paras = WBTB_Composition.document.body.all.tags("P"); //if (paras.length > 0){ // for (var i=paras.length-1; i >= 0; i--) str= paras.innerHTML + "\n" + str; //} else { str = WBTB_Composition.document.body.innerHTML; //} str=WBTB_correctUrl(str); return str; } function WBTB_correctUrl(cont) { var url=location.href.substring(0,location.href.lastIndexOf("/")+1); cont=WBTB_rCode(cont,location.href+"#","#"); cont=WBTB_rCode(cont,url,""); return cont; } var WBTB_bLoad=false var WBTB_pureText=true var WBTB_bTextMode=false WBTB_public_description=new WBTB_Editor function WBTB_Editor() { this.put_HtmlMode=WBTB_setMode; this.put_value=WBTB_putText; this.get_value=WBTB_getText; } function WBTB_getText() { if (WBTB_bTextMode) return WBTB_Composition.document.body.innerText; else { WBTB_cleanHtml(); return WBTB_Composition.document.body.innerHTML; } } function WBTB_putText(v) { if (WBTB_bTextMode) WBTB_Composition.document.body.innerText = v; else WBTB_Composition.document.body.innerHTML = v; } function WBTB_InitDocument(hiddenid, charset) { if (charset!=null) WBTB_charset=charset; var WBTB_bodyTag=""; var editor=WBTB_Composition; var h=document.getElementById(hiddenid); editor.document.designMode="On" editor.document.open(); editor.document.write(WBTB_bodyTag); if (h.value!="") { editor.document.write(h.value); } editor.document.write(""); editor.document.close(); editor.document.body.contentEditable = "True"; editor.document.charset=WBTB_charset; WBTB_bLoad=true; WBTB_setStyle(); //eval("WBTB_Composition.document.body.innerHTML+=(self.opener."+ htmlableID +".checked)?(self.opener."+bodyID+".value)WBTB_ubb2html(self.opener."+ bodyID +".value))"); } function WBTB_doSelectClick(str, el) { var Index = el.selectedIndex; if (Index != 0){ el.selectedIndex = 0; WBTB_format(str,el.options[Index].value); } } var WBTB_bIsIE5 = (navigator.userAgent.indexOf("IE 5") > -1) || (navigator.userAgent.indexOf("IE 6") > -1); var WBTB_edit; //selectRang var WBTB_RangeType; var WBTB_selection; //Ó¦ÓÃhtml function WBTB_specialtype(Mark1, Mark2){ var strHTML; if (WBTB_bIsIE5) WBTB_selectRange(); if (WBTB_RangeType == "Text"){ if (Mark2==null) { strHTML = "<" + Mark1 + ">" + WBTB_edit.htmlText + ""; }else{ strHTML = Mark1 + WBTB_edit.htmlText + Mark2; } WBTB_edit.pasteHTML(strHTML); WBTB_Composition.focus(); WBTB_edit.select(); } } //Ñ¡ÔñÄÚÈÝÌæ»»Îı¾ function WBTB_InsertSymbol(str1) { WBTB_Composition.focus(); if (WBTB_bIsIE5) WBTB_selectRange(); WBTB_edit.pasteHTML(str1); } function WBTB_selectRange(){ WBTB_selection = WBTB_Composition.document.selection; WBTB_edit = WBTB_Composition.document.selection.createRange(); WBTB_RangeType = WBTB_Composition.document.selection.type; } function WBTB_rCode(s,a,b,i){ //sÔ­×Ö´®£¬aÒª»»µôpattern£¬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); } //Ìá½»Êý¾Ýµ½opener£¬ÒÑÎÞÓà /* function WBTB_handin() { if (!WBTB_validateMode()) return; var strHTMLbegin; var strHTMLend; strHTMLbegin = ""; strHTMLend = ""; // eval("self.opener."+bodyID+".value=strHTMLbegin + WBTB_getPureHtml(WBTB_Composition.document.body.innerHTML) + strHTMLend;self.opener."+htmlableID+".checked=true;"); self.close(); } */ function WBTB_View() { if (WBTB_bTextMode) { cont=WBTB_Composition.document.body.innerText; } else { cont=WBTB_Composition.document.body.innerHTML; } cont=WBTB_correctUrl(cont); bodyTag=""; if (WBTB_filterScript) cont=WBTB_FilterScript(cont); //cont=WBTB_rCode(cont,"\\[dvnews_ad]",""); //cont=WBTB_rCode(cont,"\\[dvnews_page]","


  Next Page ...

"); preWin=window.open('preview','','left=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0'); preWin.document.open(); preWin.document.write(bodyTag); preWin.document.write(cont); preWin.document.close(); preWin.document.title="Preview"; preWin.document.charset=WBTB_charset; } // Ð޸ı༭À¸¸ß¶È function WBTB_Size(num) { var obj=document.all.WBTB_Container; if (parseInt(obj.height)+num>=300) { obj.height = parseInt(obj.height) + num; } if (num>0) { obj.width="100%"; } } /* function WBTB_ubbcode(){ if (!WBTB_validateMode()) return; cont=WBTB_getPureHtml(WBTB_Composition.document.body.innerHTML); var aryCode0 = new Array("","","","","","[/p]","","[/url]"); var aryCode1 = new Array("","","","","","","","","
    ","
      ","
    ","
","
    ","
      ","
    ","
"); var aryCode2 = new Array("
  • ","
  • ","
  • ","","","">","<","[",",aryCode[i+1]); } // eval("self.opener."+bodyID+".value+=cont;"); self.close(); } function WBTB_ubb2html(str){ if (str=="") return str; var aryCode0 = new Array("
    ","\n","","\\","","\\","","\\[/p]","
    ","\\[/url]"); var aryCode1 = new Array("","\\","","\\","","\\","","\\","
      ","\\
        ","
      ","\\
    ","
      ","\\
        ","
      ","\\
    "); var aryCode = aryCode0.concat(aryCode1); for (var i=0;i); } return str; } */ // ¿½±´Êý¾Ýµ½hidden function WBTB_CopyData(hiddenid) { d = WBTB_Composition.document; if (WBTB_bTextMode) { cont=d.body.innerText; }else{ cont=d.body.innerHTML; } cont=WBTB_correctUrl(cont); if (WBTB_filterScript) cont=WBTB_FilterScript(cont); document.getElementById(hiddenid).value = cont; if (document.getElementById(hiddenid).value == '

     

    ') { document.getElementById(hiddenid).value = ''; } } function WBTB_insert(cons) { var WBTB_Composition; WBTB_Composition.document.body.innerHTML=cons; } function WBTB_help() { showModalDialog("wbTextBox/help.html", "", "dialogWidth:13.5em; dialogHeight:12.5em; status:0; help:0"); } 点击插入图片后出现如下画面,我不明白那是怎么出现的

    提问者:lozenz   08-13 19:07
    答复
    我也来回答:
    不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

    为防止灌水,您需要计算一道数学题: 答案:
    55 + 12 = ? 请将计算结果填在上面

     
    []
    ©2007 PhpRes.COM