查看HTML源代码
" var bTextMode=false public_description=new Editor function document.onreadystatechange(){ if (YInitialized) return; YInitialized = true; var i, s, curr; for (i=0; i TotalLen) TotalLen = TB.TBWidth; } var PrevTB; var LastStart = 0; var RelTop = 0; var LastWid, CurrWid; var TB = yToolbars[0]; TB.style.posTop = 0; TB.style.posLeft = 0; var Start = TB.TBWidth; for (i = 1 ; i < yToolbars.length ; i++) { PrevTB = TB; TB = yToolbars[i]; CurrWid = TB.TBWidth; if ((Start + CurrWid) > ScrWid) { Start = 0; LastWid = TotalLen - LastStart; } else { LastWid = PrevTB.TBWidth; RelTop -= TB.offsetHeight; } TB.style.posTop = RelTop; TB.style.posLeft = Start; PrevTB.style.width = LastWid; LastStart = Start; Start += CurrWid; } TB.style.width = TotalLen - LastStart; i--; TB = yToolbars[i]; var TBInd = TB.sourceIndex; var A = TB.document.all; var item; for (i in A) { item = A.item(i); if (! item) continue; if (! item.style) continue; if (item.sourceIndex <= TBInd) continue; if (item.style.position == "absolute") continue; item.style.posTop = RelTop; } } function DoLayout() { LayoutTBs(); } function BtnMouseOver() { if (event.srcElement.tagName != "IMG") return false; var image = event.srcElement; var element = image.parentElement; if (image.className == "Ico") element.className = "BtnMouseOverUp"; else if (image.className == "IcoDown") element.className = "BtnMouseOverDown"; event.cancelBubble = true; } function BtnMouseOut() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; yRaisedElement = null; element.className = "Btn"; image.className = "Ico"; event.cancelBubble = true; } function BtnMouseDown() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; event.returnValue=false; return false; } var image = event.srcElement; var element = image.parentElement; element.className = "BtnMouseOverDown"; image.className = "IcoDown"; event.cancelBubble = true; event.returnValue=false; return false; } function BtnMouseUp() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; if(navigator.userAgent.indexOf("MSIE 6.0")>0 ) { if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()"); // if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "onclick(event)"); } else { // if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()"); if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "onclick(event)"); } element.className = "BtnMouseOverUp"; image.className = "Ico"; event.cancelBubble = true; return false; } function getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement; return start; } function cleanHtml() { var fonts = HtmlEdit.document.body.all.tags("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 getPureHtml() { var str = ""; var paras = HtmlEdit.document.body.all.tags("P"); if (paras.length > 0) { for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str; } else { str = HtmlEdit.document.body.innerHTML; } return str; } function Editor() { this.put_HtmlMode=setMode; this.put_value=putText; this.get_value=getText; } function getText() { if (bTextMode) return HtmlEdit.document.body.innerText; else { cleanHtml(); cleanHtml(); return HtmlEdit.document.body.innerHTML; } } function putText(v) { if (bTextMode) HtmlEdit.document.body.innerText = v; else HtmlEdit.document.body.innerHTML = v; } function UserDialog(what) { if (!validateMode()) return; HtmlEdit.document.execCommand(what, true); pureText = false; HtmlEdit.focus(); } function validateMode() { if (! bTextMode) return true; alert("请取消“查看HTML源代码”选项,然后再使用系统编辑功能!"); HtmlEdit.focus(); return false; } function format(what,opt) { if (!validateMode()) return; if (opt=="removeFormat") { what=opt; opt=null; } if (opt==null) HtmlEdit.document.execCommand(what); else HtmlEdit.document.execCommand(what,"",opt); pureText = false; HtmlEdit.focus(); } function setMode(newMode) { var cont; bTextMode = newMode; if (bTextMode) { cleanHtml(); cleanHtml(); cont=HtmlEdit.document.body.innerHTML; HtmlEdit.document.body.innerText=cont; } else { cont=HtmlEdit.document.body.innerText; HtmlEdit.document.body.innerHTML=cont; } HtmlEdit.focus(); } function foreColor() { if (! validateMode()) return; var arr = showModalDialog("selcolor.asp", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0"); if (arr != null) format('forecolor', arr); else HtmlEdit.focus(); } function InsertTable() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("table.asp", "", "dialogWidth:300pt;dialogHeight:236pt;help:0;status:0"); if (arr != null){ range.pasteHTML(arr); } HtmlEdit.focus(); } function pic() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("pic.html", "", "dialogWidth:30em; dialogHeight:15em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") a=ss[0]; b=ss[1]; c=ss[2]; d=ss[3]; e=ss[4]; f=ss[5]; g=ss[6]; h=ss[7]; i=ss[8]; str1=""+b+"" content=HtmlEdit.document.body.innerHTML; content=content+str1; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function imgs(filepath,ImgWidth,ImgHeight) { if (filepath != null) { var str1; str1="" content=HtmlEdit.document.body.innerHTML; content=content+str1; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function swf() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("flash.html", "", "dialogWidth:30em; dialogHeight:10em; 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=HtmlEdit.document.body.innerHTML; content=content+string; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function hr() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("hr.htm", "", "dialogWidth:30em; dialogHeight:12em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") a=ss[0]; b=ss[1]; c=ss[2]; d=ss[3]; e=ss[4]; var str1; str1="" content=HtmlEdit.document.body.innerHTML; content=content+str1; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function FIELDSET() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("fieldset.htm", "", "dialogWidth:25em; dialogHeight:10em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") a=ss[0]; b=ss[1]; c=ss[2]; d=ss[3]; var str1; str1="
标题内容
" content=HtmlEdit.document.body.innerHTML; content=content+str1; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function iframe() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("iframe.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") a=ss[0]; b=ss[1]; c=ss[2]; d=ss[3]; e=ss[4]; f=ss[5]; g=ss[6]; var str1; str1="" content=HtmlEdit.document.body.innerHTML; content=content+str1; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function wmv() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("media.html", "", "dialogWidth:30em; dialogHeight:10em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") path=ss[0]; row=ss[1]; col=ss[2]; var string; //string="" string="" content=HtmlEdit.document.body.innerHTML; content=content+string; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function rm() { if (! validateMode()) return; HtmlEdit.focus(); var range = HtmlEdit.document.selection.createRange(); var arr = showModalDialog("rm.html", "", "dialogWidth:30em; dialogHeight:10em; status:0;help:0"); if (arr != null){ var ss; ss=arr.split("*") path=ss[0]; row=ss[1]; col=ss[2]; var string; //string="
" string="" content=HtmlEdit.document.body.innerHTML; content=content+string; HtmlEdit.document.body.innerHTML=content; } else HtmlEdit.focus(); } function specialtype(Mark){ if (!Error()) return; var sel,RangeType sel = HtmlEdit.document.selection.createRange(); RangeType = HtmlEdit.document.selection.type; if (RangeType == "Text"){ sel.pasteHTML("<" + Mark + ">" + sel.text + ""); sel.select(); } HtmlEdit.focus(); } function help() { var arr = showModalDialog("help.asp", "", "dialogWidth:580px; dialogHeight:460px; status:0"); } function save() { if (bTextMode){ //编辑器嵌入其他网页时使用下面这一句(请将form1改成相应表单名) parent.myform.Content.value=HtmlEdit.document.body.innerText; //单独打开编辑器时使用下面这一句(请将form1改成相应表单名) // self.opener.form1.content.value+=HtmlEdit.document.body.innerText; } else{ //编辑器嵌入其他网页时使用下面这一句(请将form1改成相应表单名) parent.myform.Content.value=HtmlEdit.document.body.innerHTML; //单独打开编辑器时使用下面这一句(请将form1改成相应表单名) // self.opener.form1.content.value+=HtmlEdit.document.body.innerHTML; } HtmlEdit.focus(); return false; }